pub struct StaticRef<T> { /* private fields */ }
Expand description
A pointer to statically allocated mutable data such as memory mapped I/O registers.
This is a simple wrapper around a raw pointer that encapsulates an unsafe
dereference in a safe manner. It serve the role of creating a &'static T
given a raw address and acts similarly to extern
definitions, except
StaticRef
is subject to module and crate boundaries, while extern
definitions can be imported anywhere.
Because this defers the actual dereference, this can be put in a const
,
whereas const I32_REF: &'static i32 = unsafe { &*(0x1000 as *const i32) };
will always fail to compile since 0x1000
doesn’t have an allocation at
compile time, even if it’s known to be a valid MMIO address.
Implementations§
Trait Implementations§
impl<T> Copy for StaticRef<T>
Auto Trait Implementations§
impl<T> Freeze for StaticRef<T>
impl<T> RefUnwindSafe for StaticRef<T>where
T: RefUnwindSafe,
impl<T> !Send for StaticRef<T>
impl<T> !Sync for StaticRef<T>
impl<T> Unpin for StaticRef<T>
impl<T> UnwindSafe for StaticRef<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