Trait bevy_internal::reflect::GetTupleStructField
source · pub trait GetTupleStructField {
// Required methods
fn get_field<T>(&self, index: usize) -> Option<&T>
where T: Reflect;
fn get_field_mut<T>(&mut self, index: usize) -> Option<&mut T>
where T: Reflect;
}
Expand description
A convenience trait which combines fetching and downcasting of tuple struct fields.
§Example
use bevy_reflect::{GetTupleStructField, Reflect};
#[derive(Reflect)]
struct Foo(String);
let mut foo = Foo("Hello, world!".to_string());
foo.get_field_mut::<String>(0).unwrap().truncate(5);
assert_eq!(foo.get_field::<String>(0), Some(&"Hello".to_string()));
Required Methods§
Object Safety§
This trait is not object safe.