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.
This commit is contained in:
Nicola Papale 2023-08-03 00:01:56 +02:00 committed by GitHub
parent d6e95e9570
commit 77fa8a9a9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1413,9 +1413,16 @@ macro_rules! impl_system_param_tuple {
all_tuples!(impl_system_param_tuple, 0, 16, P); all_tuples!(impl_system_param_tuple, 0, 16, P);
/// Contains type aliases for built-in [`SystemParam`]s with `'static` lifetimes. /// 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. /// 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 /// [`SystemParam`]: super::SystemParam
pub mod lifetimeless { pub mod lifetimeless {
/// A [`Query`](super::Query) with `'static` lifetimes. /// A [`Query`](super::Query) with `'static` lifetimes.