You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Objective
`bsn!` should support Rust's "name shorthand syntax":
```rust
let value = 10;
Foo { value }
```
## Solution
Add support, both for normal types and "props":
```rust
let value = 10;
bsn! {
Foo { value }
}
let value = 10;
bsn! {
@foo { @value }
}
```
This also changes generated internal bsn! variables to use `__X`
formatting everywhere to avoid conflicts with user-defined variables (we
were already using this strategy in some places ... this just uses it
everywhere).
## Testing
- added a test
---------
Co-authored-by: François Mockers <mockersf@gmail.com>
Co-authored-by: urben1680 <55257931+urben1680@users.noreply.github.com>
Copy file name to clipboardExpand all lines: crates/bevy_scene/src/lib.rs
+61-2Lines changed: 61 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -959,6 +959,7 @@ use bevy_ecs::prelude::*;
959
959
/// | `CompA(val)`<br>`CompA(val, val)` | Tuple Component with some fields specified. Unspecified fields will be default, see [patching](self#patching) |
960
960
/// | `CompA { name: val }` | Component with some fields specified. Unspecified fields will be default, see [patching](self#patching) |
961
961
/// | `mymodule::CompA { name: val }` | Same as above, but referring to the component by module path |
962
+
/// | `CompA { name }` | Component with Rust's "field assignment shorthand". Evaluates to `CompA { name: name.into() }` |
962
963
/// | `MyEnum::Variant` | Enum Component `MyEnum` with the `Variant` variant |
963
964
/// | `template_value(component)` | Insert the component value from a variable `component` |
964
965
/// | `template_value(CompA::from_str("foo"))` | Insert the component value by immediately calling the constructor |
0 commit comments