Struct runestick::Ref[][src]

pub struct Ref<T: ?Sized> { /* fields omitted */ }

A strong reference to the given type.

Implementations

impl<T: ?Sized> Ref<T>[src]

pub fn map<U: ?Sized, F>(this: Self, f: F) -> Ref<U> where
    F: FnOnce(&T) -> &U, 
[src]

Map the interior reference of an owned mutable value.

Examples

use runestick::{Ref, Shared};

let vec = Shared::<Vec<u32>>::new(vec![1, 2, 3, 4]);
let vec = vec.into_ref()?;
let value: Ref<[u32]> = Ref::map(vec, |vec| &vec[0..2]);

assert_eq!(&*value, &[1u32, 2u32][..]);

pub fn try_map<U: ?Sized, F>(this: Self, f: F) -> Option<Ref<U>> where
    F: FnOnce(&T) -> Option<&U>, 
[src]

Try to map the reference to a projection.

Examples

use runestick::{Ref, Shared};

let vec = Shared::<Vec<u32>>::new(vec![1, 2, 3, 4]);
let vec = vec.into_ref()?;
let value: Option<Ref<[u32]>> = Ref::try_map(vec, |vec| vec.get(0..2));

assert_eq!(value.as_deref(), Some(&[1u32, 2u32][..]));

pub fn into_raw(this: Self) -> (*const T, RawRef)[src]

Convert into a raw pointer and associated raw access guard.

Safety

The returned pointer must not outlive the associated guard, since this prevents other uses of the underlying data which is incompatible with the current.

Trait Implementations

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

impl<T: ?Sized> Deref for Ref<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> FromValue for Ref<T> where
    T: Any
[src]

impl FromValue for Ref<String>[src]

impl FromValue for Ref<Function>[src]

impl FromValue for Ref<Object>[src]

impl FromValue for Ref<Range>[src]

impl FromValue for Ref<Tuple>[src]

impl FromValue for Ref<Vec>[src]

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

Blanket implementation for owned references.

Auto Trait Implementations

impl<T> !RefUnwindSafe for Ref<T>

impl<T> !Send for Ref<T>

impl<T> !Sync for Ref<T>

impl<T: ?Sized> Unpin for Ref<T>

impl<T> !UnwindSafe for Ref<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, 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.