Struct runestick::Ref[][src]

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

A strong reference to the given type.

Implementations

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][..]);

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][..]));

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

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Try to convert to the given type, from the given value.

Try to convert to the given type, from the given value.

Try to convert to the given type, from the given value.

Try to convert to the given type, from the given value.

Try to convert to the given type, from the given value.

Try to convert to the given type, from the given value.

Try to convert to the given type, from the given value.

Blanket implementation for owned references.

Convert into a type hash.

Access diagnostical information on the value type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.