pub struct ProtectedVal<'a> { /* private fields */ }Expand description
Holds a value from the Vm that is guaranteed to not be garbage collected.
The underlying value is protected from garbage collection until ProtectedVal is dropped.
Implementations§
Source§impl<'a> ProtectedVal<'a>
impl<'a> ProtectedVal<'a>
Source§impl<'a> ProtectedVal<'a>
impl<'a> ProtectedVal<'a>
Sourcepub fn map<T>(&mut self, f: impl Fn(&mut Vm, &ProtectedVal<'a>) -> T) -> T
pub fn map<T>(&mut self, f: impl Fn(&mut Vm, &ProtectedVal<'a>) -> T) -> T
Maps an Option<T> to Option<U> by applying a function to a contained value (if Some)
or returns None (if None).
Sourcepub fn try_str(&'a self) -> Result<&'a str, Val<'_>>
pub fn try_str(&'a self) -> Result<&'a str, Val<'_>>
Try to get the string as a value or return its underlying value.
Sourcepub fn try_custom<T: CustomType>(
&self,
) -> Result<CustomValRef<'_, T>, CustomValError>
pub fn try_custom<T: CustomType>( &self, ) -> Result<CustomValRef<'_, T>, CustomValError>
Try to get the custom value of type T or return its underlying value if self is not of
type T.
Sourcepub fn try_custom_mut<T: CustomType>(
&self,
) -> Result<CustomValMut<'_, T>, CustomValError>
pub fn try_custom_mut<T: CustomType>( &self, ) -> Result<CustomValMut<'_, T>, CustomValError>
Methods from Deref<Target = Val<'a>>§
Sourcepub fn try_custom<T: CustomType>(
&self,
vm: &'a Vm,
) -> Result<CustomValRef<'_, T>, CustomValError>
pub fn try_custom<T: CustomType>( &self, vm: &'a Vm, ) -> Result<CustomValRef<'_, T>, CustomValError>
Sourcepub fn try_custom_mut<T: CustomType>(
&self,
vm: &'a Vm,
) -> Result<CustomValMut<'_, T>, CustomValError>
pub fn try_custom_mut<T: CustomType>( &self, vm: &'a Vm, ) -> Result<CustomValMut<'_, T>, CustomValError>
Trait Implementations§
Source§impl<'a> Debug for ProtectedVal<'a>
impl<'a> Debug for ProtectedVal<'a>
Source§impl<'a> Deref for ProtectedVal<'a>
impl<'a> Deref for ProtectedVal<'a>
Source§impl<'a> Display for ProtectedVal<'a>
impl<'a> Display for ProtectedVal<'a>
Auto Trait Implementations§
impl<'a> Freeze for ProtectedVal<'a>
impl<'a> !RefUnwindSafe for ProtectedVal<'a>
impl<'a> Send for ProtectedVal<'a>
impl<'a> !Sync for ProtectedVal<'a>
impl<'a> Unpin for ProtectedVal<'a>
impl<'a> !UnwindSafe for ProtectedVal<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more