pub struct Immortal<T> { /* private fields */ }
Expand description
A value that is truly owned by the process itself.
Using this type is similar to using a ProcessOwned
with lazy_static
, except the value can only be dropped
when the process terminates. This can lead to memory
leaks, but it can also be useful for values that are
used throughout the entire process.
Implementations§
Source§impl<T> Immortal<T>
impl<T> Immortal<T>
Sourcepub unsafe fn new(value: T) -> Self
pub unsafe fn new(value: T) -> Self
Creates a new Immortal
value.
§Safety
This function is unsafe because it allocates memory and stores a raw pointer to it. The memory is never freed, so it is up to the caller to ensure that the memory is not leaked.
§Examples
use process_owned::Immortal;
unsafe {
let immortal = Immortal::new(5);
assert_eq!(*immortal, 5);
}
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Immortal<T>
impl<T> RefUnwindSafe for Immortal<T>where
T: RefUnwindSafe,
impl<T> !Send for Immortal<T>
impl<T> !Sync for Immortal<T>
impl<T> Unpin for Immortal<T>
impl<T> UnwindSafe for Immortal<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more