pub struct StaticArc<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::{Arc, ArcBorrow, StaticArc};
const VALUE: u32 = 10;
static SR: StaticArc<u32> = StaticArc::new(VALUE);
fn takes_ref_borrow(v: ArcBorrow<'_, u32>) {
assert_eq!(*v, VALUE);
}
fn takes_ref(v: Arc<u32>) {
assert_eq!(*v, VALUE);
}
takes_ref_borrow(SR.as_arc_borrow());
takes_ref(SR.as_arc_borrow().into());
Implementations
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for StaticArc<T>
impl<T: ?Sized> Send for StaticArc<T>where
T: Send,
impl<T: ?Sized> Unpin for StaticArc<T>where
T: Unpin,
impl<T: ?Sized> UnwindSafe for StaticArc<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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