Skip to content

Commit

Permalink
Merge pull request #2 from Congyuwang/remove_feature_offset_of
Browse files Browse the repository at this point in the history
remove '[feature(offset_of)]' as it is stablized in 1.87 nightly
  • Loading branch information
Congyuwang authored Feb 18, 2024
2 parents fbec5ee + 5ba71ed commit dfc6773
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(offset_of)]
#![feature(inline_const)]
use std::{
marker::PhantomData,
mem::{offset_of, MaybeUninit},
Expand Down Expand Up @@ -132,7 +130,7 @@ impl<T> Drop for LinkNode<T> {
impl<T> ListHead<T> {
#[inline(always)]
unsafe fn ptr(&mut self) -> NonNull<ListHead<T>> {
NonNull::new_unchecked(self as *mut ListHead<T>)
NonNull::from(self)
}

/// Called when node is created.
Expand Down Expand Up @@ -168,12 +166,13 @@ impl<T> ListHead<T> {
/// is still complete.
#[inline(always)]
unsafe fn add(&mut self, other: &mut ListHead<T>) {
let next = self.next.assume_init_mut().as_mut();
let other_ptr = other.ptr();

other.prev.write(self.ptr());
other.next = self.next;

let next = self.next.assume_init_mut().as_mut();
next.prev.write(other.ptr());
self.next.write(other.ptr());
next.prev.write(other_ptr);
self.next.write(other_ptr);
}

#[inline(always)]
Expand Down Expand Up @@ -266,6 +265,6 @@ impl<T> ListHead<T> {

#[inline(always)]
const fn offset() -> isize {
const { -(offset_of!(Inner<T>, list) as isize) }
-(offset_of!(Inner<T>, list) as isize)
}
}

0 comments on commit dfc6773

Please sign in to comment.