Skip to content

Commit 4078273

Browse files
committed
fix bevy_reflect README (#5477)
# Objective - Code in `bevy_reflect` README doesn't compile ## Solution - Fix it
1 parent 2d2ea33 commit 4078273

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crates/bevy_reflect/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct Foo {
2828
#[derive(Reflect)]
2929
struct Bar(String);
3030

31-
#[derive(Reflect)]
31+
#[derive(Reflect, FromReflect)]
3232
struct Baz {
3333
value: f32,
3434
}
@@ -77,7 +77,7 @@ assert_eq!(value, 3.14);
7777
```rust ignore
7878
for (i, value: &Reflect) in foo.iter_fields().enumerate() {
7979
let field_name = foo.name_at(i).unwrap();
80-
if let Ok(value) = value.downcast_ref::<u32>() {
80+
if let Some(value) = value.downcast_ref::<u32>() {
8181
println!("{} is a u32 with the value: {}", field_name, *value);
8282
}
8383
}
@@ -137,7 +137,7 @@ let reflect_value: Box<dyn Reflect> = Box::new(MyType {
137137
// don't know the type at compile time?
138138

139139
// Normally in rust we would be out of luck at this point. Lets use our new reflection powers to do something cool!
140-
let mut type_registry = TypeRegistry::default()
140+
let mut type_registry = TypeRegistry::default();
141141
type_registry.register::<MyType>();
142142

143143
// The #[reflect] attribute we put on our DoThing trait generated a new `ReflectDoThing` struct, which implements TypeData.

0 commit comments

Comments
 (0)