pub struct StaticRef<T: ?Sized> { /* private fields */ }
Expand description
Allows the creation of “reference-counted” globals.
This is achieved by biasing the refcount with +1, which ensures that the count never drops back
to zero (unless buggy unsafe code incorrectly decrements without owning an increment) and
therefore also ensures that drop
is never called.
Examples
use kernel::sync::{Ref, RefBorrow, StaticRef};
const VALUE: u32 = 10;
static SR: StaticRef<u32> = StaticRef::new(VALUE);
fn takes_ref_borrow(v: RefBorrow<'_, u32>) {
assert_eq!(*v, VALUE);
}
fn takes_ref(v: Ref<u32>) {
assert_eq!(*v, VALUE);
}
takes_ref_borrow(SR.as_ref_borrow());
takes_ref(SR.as_ref_borrow().into());
Implementations
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for StaticRef<T>
impl<T: ?Sized> Send for StaticRef<T> where
T: Send,
impl<T: ?Sized> Unpin for StaticRef<T> where
T: Unpin,
impl<T: ?Sized> UnwindSafe for StaticRef<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more