We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Opaque::raw_get
1 parent 553a414 commit 87018c9Copy full SHA for 87018c9
rust/kernel/types.rs
@@ -15,7 +15,7 @@ use core::{
15
mem::MaybeUninit,
16
ops::{self, Deref, DerefMut},
17
pin::Pin,
18
- ptr::NonNull,
+ ptr::{addr_of, NonNull},
19
};
20
21
/// Permissions.
@@ -316,6 +316,18 @@ impl<T> Opaque<T> {
316
pub fn get(&self) -> *mut T {
317
UnsafeCell::raw_get(self.0.as_ptr())
318
}
319
+
320
+ /// Gets the value behind `this`.
321
+ ///
322
+ /// This function is useful to get access to the value without creating intermeditate
323
+ /// references.
324
325
+ /// # Safety
326
327
+ /// The pointer supplied is valid.
328
+ pub unsafe fn raw_get(this: *const Self) -> *mut T {
329
+ UnsafeCell::raw_get(addr_of!((*this).0).cast::<UnsafeCell<T>>())
330
+ }
331
332
333
/// A bitmask.
0 commit comments