Skip to content

Commit

Permalink
Add a paragraph to the lifetimeless module doc (#9312)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
nicopap committed Aug 2, 2023
1 parent d6e95e9 commit 77fa8a9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/bevy_ecs/src/system/system_param.rs
Expand Up @@ -1413,9 +1413,16 @@ macro_rules! impl_system_param_tuple {
all_tuples!(impl_system_param_tuple, 0, 16, P);

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

0 comments on commit 77fa8a9

Please sign in to comment.