diff options
| author | Emil Fresk <emil.fresk@gmail.com> | 2023-01-28 13:21:44 +0100 |
|---|---|---|
| committer | Henrik Tjäder <henrik@tjaders.com> | 2023-03-01 00:33:36 +0100 |
| commit | 3050fc0591f087a4fbe08840c69633e89d3f58a7 (patch) | |
| tree | 63c26184993ce42c63102e174d781c5d52da6623 /rtic-time/src/linked_list.rs | |
| parent | 5908d5bdbc3a3daf741d58b925fa280a3a81bf6a (diff) | |
Use `Pin` in the linked lists
Diffstat (limited to 'rtic-time/src/linked_list.rs')
| -rw-r--r-- | rtic-time/src/linked_list.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/rtic-time/src/linked_list.rs b/rtic-time/src/linked_list.rs index 52a955b..de5ea2a 100644 --- a/rtic-time/src/linked_list.rs +++ b/rtic-time/src/linked_list.rs @@ -1,6 +1,7 @@ //! ... use core::marker::PhantomPinned; +use core::pin::Pin; use core::sync::atomic::{AtomicPtr, Ordering}; use critical_section as cs; @@ -92,8 +93,10 @@ impl<T: PartialOrd + Clone> LinkedList<T> { /// Insert a new link into the linked list. /// The return is (was_empty, address), where the address of the link is for use with `delete`. - pub fn insert(&self, val: &mut Link<T>) -> (bool, usize) { + pub fn insert(&self, val: Pin<&mut Link<T>>) -> (bool, usize) { cs::with(|_| { + // SAFETY: This datastructure does not move the underlying value. + let val = unsafe { val.get_unchecked_mut() }; let addr = val as *const _ as usize; // Make sure all previous writes are visible |
