VariableRefMut

Struct VariableRefMut 

Source
pub struct VariableRefMut<'a>(/* private fields */);
Expand description

Managed mutable reference to a variable.

This type allows you to mutate a variable in a variable set while maintaining the invariants of the variable set. To obtain an instance of VariableRefMut, use VariableSet::get_or_new.

Implementations§

Source§

impl VariableRefMut<'_>

Source

pub fn assign<V: Into<Value>, L: Into<Option<Location>>>( &mut self, value: V, location: L, ) -> Result<(Option<Value>, Option<Location>), AssignError>

Assigns a value to this variable.

The value and location operands are set to the value and last_assigned_location fields of this variable, respectively. If successful, this function returns the previous value and location.

This function fails if this variable is read-only. In that case, the error contains the given operands as well as the location where this variable was made read-only.

Source

pub fn export(&mut self, is_exported: bool)

Sets whether this variable is exported or not.

Source

pub fn make_read_only(&mut self, location: Location)

Makes this variable read-only.

The location operand is set to the read_only_location field of this variable unless this variable is already read-only.

Source

pub fn set_quirk(&mut self, quirk: Option<Quirk>)

Sets the quirk of this variable.

This function overwrites any existing quirk of this variable.

Methods from Deref<Target = Variable>§

Source

pub fn is_read_only(&self) -> bool

Whether this variable is read-only or not.

Source

pub fn expand(&self, location: &Location) -> Expansion<'_>

Returns the value of this variable, applying any quirk.

If this variable has no Quirk, this function just returns self.value converted to Expansion. Otherwise, the effect of the quirk is applied to the value and the result is returned.

This function requires the location of the parameter expanding this variable, so that Quirk::LineNumber can yield the line number of the location.

Trait Implementations§

Source§

impl<'a> Debug for VariableRefMut<'a>

Source§

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

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

impl Deref for VariableRefMut<'_>

Source§

type Target = Variable

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Variable

Dereferences the value.
Source§

impl<'a> From<&'a mut Variable> for VariableRefMut<'a>

Source§

fn from(variable: &'a mut Variable) -> Self

Converts to this type from the input type.
Source§

impl<'a> PartialEq for VariableRefMut<'a>

Source§

fn eq(&self, other: &VariableRefMut<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for VariableRefMut<'a>

Source§

impl<'a> StructuralPartialEq for VariableRefMut<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for VariableRefMut<'a>

§

impl<'a> !RefUnwindSafe for VariableRefMut<'a>

§

impl<'a> !Send for VariableRefMut<'a>

§

impl<'a> !Sync for VariableRefMut<'a>

§

impl<'a> Unpin for VariableRefMut<'a>

§

impl<'a> !UnwindSafe for VariableRefMut<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.