[][src]Struct arae::Cursor

pub struct Cursor<T> { /* fields omitted */ }

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]

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]

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]

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]

impl<T> From<Cursor<T>> for AtomicCursor<T>[src]

impl<T> Ord for Cursor<T>[src]

impl<T> PartialEq<Cursor<T>> for Cursor<T>[src]

impl<T> PartialOrd<Cursor<T>> for Cursor<T>[src]

Auto Trait Implementations

impl<T> !Send for Cursor<T>

impl<T> !Sync for Cursor<T>

impl<T> Unpin for Cursor<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.