Struct lucia_lang::gc::RefMut

source ·
pub struct RefMut<'a, T: ?Sized + 'a> { /* private fields */ }
Expand description

A wrapper type for a mutably borrowed value from a RefCell<T>.

Implementations§

source§

impl<'a, T: ?Sized> RefMut<'a, T>

source

pub fn map<U: ?Sized, F>(orig: RefMut<'a, T>, f: F) -> RefMut<'a, U>where F: FnOnce(&mut T) -> &mut U,

Makes a new RefMut for a component of the borrowed data, e.g., an enum variant.

The RefCell is already mutably borrowed, so this cannot fail.

This is an associated function that needs to be used as RefMut::map(...). A method would interfere with methods of the same name on the contents of a RefCell used through Deref.

source

pub fn filter_map<U: ?Sized, F>( orig: RefMut<'a, T>, f: F ) -> Result<RefMut<'a, U>, Self>where F: FnOnce(&mut T) -> Option<&mut U>,

Makes a new RefMut for an optional component of the borrowed data. The original guard is returned as an Err(..) if the closure returns None.

The RefCell is already mutably borrowed, so this cannot fail.

This is an associated function that needs to be used as RefMut::filter_map(...). A method would interfere with methods of the same name on the contents of a RefCell used through Deref.

source

pub fn map_split<U: ?Sized, V: ?Sized, F>( orig: RefMut<'a, T>, f: F ) -> (RefMut<'a, U>, RefMut<'a, V>)where F: FnOnce(&mut T) -> (&mut U, &mut V),

Splits a RefMut into multiple RefMuts for different components of the borrowed data.

The underlying RefCell will remain mutably borrowed until both returned RefMuts go out of scope.

The RefCell is already mutably borrowed, so this cannot fail.

This is an associated function that needs to be used as RefMut::map_split(...). A method would interfere with methods of the same name on the contents of a RefCell used through Deref.

Trait Implementations§

source§

impl<T: ?Sized + Debug> Debug for RefMut<'_, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: ?Sized> Deref for RefMut<'_, T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<T: ?Sized> DerefMut for RefMut<'_, T>

source§

fn deref_mut(&mut self) -> &mut T

Mutably dereferences the value.
source§

impl<T: ?Sized + Display> Display for RefMut<'_, T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for RefMut<'a, T>

§

impl<'a, T> !Send for RefMut<'a, T>

§

impl<'a, T> !Sync for RefMut<'a, T>

§

impl<'a, T: ?Sized> Unpin for RefMut<'a, T>

§

impl<'a, T> !UnwindSafe for RefMut<'a, T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.