Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace uses of ptr::Shared with ptr::NonNull (#20) #25

Merged
merged 1 commit into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions intruder_alarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extern crate alloc;
use core::{fmt, mem};
use core::default::Default;
use core::ops::Deref;
use core::ptr::Shared;
use core::ptr::NonNull;

pub mod doubly;

Expand All @@ -65,10 +65,10 @@ pub unsafe trait OwningRef<T: ?Sized>: Deref<Target = T> {
unsafe fn from_ptr(p: *const Self::Target) -> Self;
}

/// A `Link` provides an [`Option`]-like interface to a [`Shared`] pointer.
/// A `Link` provides an [`Option`]-like interface to a [`NonNull`] pointer.
///
///
pub struct Link<T: ?Sized>(Option<Shared<T>>);
pub struct Link<T: ?Sized>(Option<NonNull<T>>);

// ===== impl OwningRef =====

Expand Down Expand Up @@ -178,7 +178,7 @@ impl<T: ?Sized> Link<T> {
where
R: OwningRef<T>,
{
Link(Shared::new(reference.into_ptr() as *mut _))
Link(NonNull::new(reference.into_ptr() as *mut _))
}
}

Expand All @@ -199,20 +199,20 @@ impl<T> Default for Link<T> {

impl<T: ?Sized> Copy for Link<T>
where
Option<Shared<T>>: Copy,
Option<NonNull<T>>: Copy,
{
}
// impl<'a, T> From<&'a T> for Link<T> {
// #[inline]
// fn from(reference: &'a T) -> Self {
// Link(Some(Shared::from(reference)))
// Link(Some(NonNull::from(reference)))
// }
// }

// impl<'a, T> From<&'a mut T> for Link<T> {
// #[inline]
// fn from(reference: &'a mut T) -> Self {
// Link(Some(Shared::from(reference)))
// Link(Some(NonNull::from(reference)))
// }
// }

Expand All @@ -227,7 +227,7 @@ where

// {
// fn from(reference: R) -> Self {
// Link(Shared::new(reference.into_ptr() as *mut _))
// Link(NonNull::new(reference.into_ptr() as *mut _))
// }
// }

Expand Down
4 changes: 2 additions & 2 deletions slabby/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pub struct Page<T: Sized> {

/// Length of the page.
len: usize,
/* next: Shared<Page<T>>,
* prev: Shared<Page<T>>, */
/* next: NonNull<Page<T>>,
* prev: NonNull<Page<T>>, */
}

#[cfg(test)]
Expand Down