[−][src]Struct arae::Cursor
An structure that represents a location within a Cursed
structure.
A Cursor
is created from and used with initialized its owning Cursed
structure, however if the structure is dropped, will point to invalid memory.
Safety is achieved via Cursor
validating it's owned by the Cursed
structure.
Methods
impl<T> Cursor<T>
[src]
pub fn new(ptr: NonNull<T>) -> Self
[src]
Constructs a new Cursor
given a non-null pointer.
pub fn get<C>(self, cursed: &C) -> &T where
C: Cursed<T>,
[src]
C: Cursed<T>,
Returns a reference to the element the Cursor
is pointing to.
Example
use arae::{CurVec, Bounded}; let mut vec: CurVec<_> = vec![0].into(); let cursor = vec.head(); assert_eq!(*cursor.get(&vec), 0);
Panics
Panics if cursed
does not own self.
pub fn get_mut<C>(self, cursed: &mut C) -> &mut T where
C: Cursed<T>,
[src]
C: Cursed<T>,
Returns a mutable reference to the element the Cursor
is pointing to.
Example
use arae::{CurVec, Bounded}; let mut vec: CurVec<_> = vec![0].into(); let cursor = vec.head(); *cursor.get_mut(&mut vec) = 1; assert_eq!(*cursor.get(&vec), 1);
Panics
Panics if cursed
does not own self.
pub unsafe fn new_unchecked(ptr: *mut T) -> Self
[src]
Constructs a new Cursor
given a unchecked pointer.
Safety
Must not be null, see NonNull::new_unchecked
safety notes.
pub fn ptr(self) -> NonNull<T>
[src]
Returns the Cursor
's underlying pointer.
pub fn into_atomic(self) -> AtomicCursor<T>
[src]
Converts the cursor into an atomic variant.
Trait Implementations
impl<T> Clone for Cursor<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Copy for Cursor<T>
[src]
impl<T> Debug for Cursor<T>
[src]
impl<T> Eq for Cursor<T>
[src]
impl<T> From<AtomicCursor<T>> for Cursor<T>
[src]
fn from(cursor: AtomicCursor<T>) -> Self
[src]
impl<T> From<Cursor<T>> for AtomicCursor<T>
[src]
impl<T> Ord for Cursor<T>
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T> PartialEq<Cursor<T>> for Cursor<T>
[src]
impl<T> PartialOrd<Cursor<T>> for Cursor<T>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,