8000 Use `UnsafeCell::raw_get` instead of `get` · rust-osdev/volatile@024ac78 · GitHub
[go: up one dir, main page]

Skip to content

Commit 024ac78

Browse files
committed
Use UnsafeCell::raw_get instead of get
1 parent 130410b commit 024ac78

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/cell.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,12 @@ impl<T, A> VolatileCell<T, A> {
128128

129129
pub fn as_ptr(&self) -> VolatilePtr<T, ReadOnly> {
130130
// UNSAFE: Safe, as we know that our internal value exists.
131-
unsafe { VolatilePtr::new_restricted(ReadOnly, NonNull::new_unchecked(self.value.get())) }
131+
unsafe {
132+
VolatilePtr::new_restricted(
133+
ReadOnly,
134+
NonNull::new_unchecked(UnsafeCell::raw_get(&self.value)),
135+
)
136+
}
132137
}
133138

134139
pub fn as_mut_ptr(&mut self) -> VolatilePtr<T, A>
@@ -137,7 +142,10 @@ impl<T, A> VolatileCell<T, A> {
137142
{
138143
// UNSAFE: Safe, as we know that our internal value exists.
139144
unsafe {
140-
VolatilePtr::new_restricted(A::default(), NonNull::new_unchecked(self.value.get()))
145+
VolatilePtr::new_restricted(
146+
A::default(),
147+
NonNull::new_unchecked(UnsafeCell::raw_get(&self.value)),
148+
)
141149
}
142150
}
143151

0 commit comments

Comments
 (0)
0