Trait Lifetime Copy item path Source pub trait Lifetime {
// Required methods
fn leak (&self) -> &'static Self;
fn leak_mut (&self) -> &'static mut Self;
}Expand description Trait for types that can be converted to a 'static reference.
This trait provides a way to obtain a 'static reference or mutable reference from
a reference to Self, enabling safe lifetime extension for
certain use cases where the object is known to live for the entire
program duration.
Converts a reference to Self into a 'static reference.
§ Returns
&'static Self: A reference to the instance with a 'static lifetime.
§ Safety
The address is guaranteed to be a valid Self instance
that was previously converted from a reference and is managed by the runtime.
Converts a reference to Self into a 'static mutable reference.
§ Returns
&'static mut Self: A mutable reference to the instance with a 'static lifetime.
§ Safety
The address is guaranteed to be a valid Self instance
that was previously converted from a reference and is managed by the runtime.
This trait is not dyn compatible .
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Source § Implementation of Lifetime trait for Context.
Source § Implementation of Lifetime trait for Server.