Skip to content

Add expression support for #-name shorthand #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 30, 2025

Conversation

villor
Copy link

@villor villor commented Jul 27, 2025

bevyengine#20158

The #-syntax currently allows specifying names using Idents, which is nice.

This PR extends it to also support arbitrary expressions enclosed in braces:

let n = 5;
bsn! {
     #{format!("Tab_{n}")} Node
}

@cart cart merged commit fbae074 into cart:next-gen-scenes Jul 30, 2025
@cart
Copy link
Owner

cart commented Jul 30, 2025

I like it! I had inklings of a plan to do the same thing :)

@villor
Copy link
Author

villor commented Jul 31, 2025

If it turns out string interpolation using #{format!("...")} is a very common occurence
A future idea is to also have #"..." automatically expand like #{format!("")}:

let n = 5;
bsn! {
     #"Tab_{n}" Node
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants