Skip to content

Commit 77fa8a9

Browse files
authored
Add a paragraph to the lifetimeless module doc (#9312)
# Objective The `lifetimeless` module has been a source of confusion for bevy users for a while now. ## Solution Add a couple paragraph explaining that, yes, you can use one of the type alias safely, without ever leaking any memory.
1 parent d6e95e9 commit 77fa8a9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,9 +1413,16 @@ macro_rules! impl_system_param_tuple {
14131413
all_tuples!(impl_system_param_tuple, 0, 16, P);
14141414

14151415
/// Contains type aliases for built-in [`SystemParam`]s with `'static` lifetimes.
1416-
/// This can make it more convenient to refer to these types in contexts where
1416+
/// This makes it more convenient to refer to these types in contexts where
14171417
/// explicit lifetime annotations are required.
14181418
///
1419+
/// Note that this is entirely safe and tracks lifetimes correctly.
1420+
/// This purely exists for convenience.
1421+
///
1422+
/// You can't instantiate a static `SystemParam`, you'll always end up with
1423+
/// `Res<'w, T>`, `ResMut<'w, T>` or `&'w T` bound to the lifetime of the provided
1424+
/// `&'w World`.
1425+
///
14191426
/// [`SystemParam`]: super::SystemParam
14201427
pub mod lifetimeless {
14211428
/// A [`Query`](super::Query) with `'static` lifetimes.

0 commit comments

Comments
 (0)