Skip to content

Commit 0b2e0cf

Browse files
authored
bevy_reflect: Add crate level functions feature docs (#15086)
Adds the missing section for the `functions` cargo feature of the `bevy_reflect` crate.
1 parent e19c53e commit 0b2e0cf

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

crates/bevy_reflect/src/lib.rs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,15 +454,11 @@
454454
//! but [`Reflect`] requires all types to have a `'static` lifetime.
455455
//! This makes it impossible to reflect any type with non-static borrowed data.
456456
//!
457-
//! ## Function Reflection
457+
//! ## Generic Function Reflection
458458
//!
459-
//! Another limitation is the inability to fully reflect functions and methods.
460-
//! Most languages offer some way of calling methods dynamically,
461-
//! but Rust makes this very difficult to do.
462-
//! For non-generic methods, this can be done by registering custom [type data] that
463-
//! contains function pointers.
464-
//! For generic methods, the same can be done but will typically require manual monomorphization
465-
//! (i.e. manually specifying the types the generic method can take).
459+
//! Another limitation is the inability to reflect over generic functions directly. It can be done, but will
460+
//! typically require manual monomorphization (i.e. manually specifying the types the generic method can
461+
//! take).
466462
//!
467463
//! ## Manual Registration
468464
//!
@@ -485,6 +481,17 @@
485481
//! These dependencies are used by the [Bevy] game engine and must define their reflection implementations
486482
//! within this crate due to Rust's [orphan rule].
487483
//!
484+
//! ## `functions`
485+
//!
486+
//! | Default | Dependencies |
487+
//! | :-----: | :-------------------------------: |
488+
//! | ❌ | [`bevy_reflect_derive/functions`] |
489+
//!
490+
//! This feature allows creating a [`DynamicFunction`] or [`DynamicFunctionMut`] from Rust functions. Dynamic
491+
//! functions can then be called with valid [`ArgList`]s.
492+
//!
493+
//! For more information, read the [`func`] module docs.
494+
//!
488495
//! ## `documentation`
489496
//!
490497
//! | Default | Dependencies |
@@ -540,6 +547,10 @@
540547
//! [`smallvec`]: https://docs.rs/smallvec/latest/smallvec/
541548
//! [orphan rule]: https://doc.rust-lang.org/book/ch10-02-traits.html#implementing-a-trait-on-a-type:~:text=But%20we%20can%E2%80%99t,implementation%20to%20use.
542549
//! [`bevy_reflect_derive/documentation`]: bevy_reflect_derive
550+
//! [`bevy_reflect_derive/functions`]: bevy_reflect_derive
551+
//! [`DynamicFunction`]: crate::func::DynamicFunction
552+
//! [`DynamicFunctionMut`]: crate::func::DynamicFunctionMut
553+
//! [`ArgList`]: crate::func::ArgList
543554
//! [derive `Reflect`]: derive@crate::Reflect
544555
545556
extern crate alloc;

0 commit comments

Comments
 (0)