File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 224
224
//!
225
225
//! All primitives and simple types implement `FromReflect` by relying on their [`Default`] implementation.
226
226
//!
227
+ //! # Path navigation
228
+ //!
229
+ //! The [`GetPath`] trait allows accessing arbitrary nested fields of a [`Reflect`] type.
230
+ //!
231
+ //! Using [`GetPath`], it is possible to use a path strings to access a specific field
232
+ //! of a reflected type.
233
+ //!
234
+ //! ```
235
+ //! # use bevy_reflect::{Reflect, GetPath};
236
+ //! #[derive(Reflect)]
237
+ //! struct MyStruct {
238
+ //! value: Vec<Option<u32>>
239
+ //! }
240
+ //!
241
+ //! let my_struct = MyStruct {
242
+ //! value: vec![None, None, Some(123)],
243
+ //! };
244
+ //! assert_eq!(
245
+ //! my_struct.path::<u32>(".value[2].0").unwrap(),
246
+ //! &123,
247
+ //! );
248
+ //! ```
249
+ //!
250
+ //! Check the [`GetPath`] documentation for more details.
251
+ //!
227
252
//! # Type Registration
228
253
//!
229
254
//! This crate also comes with a [`TypeRegistry`] that can be used to store and retrieve additional type metadata at runtime,
You can’t perform that action at this time.
0 commit comments