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<'_>
impl VariableRefMut<'_>
Sourcepub fn assign<V: Into<Value>, L: Into<Option<Location>>>(
&mut self,
value: V,
location: L,
) -> Result<(Option<Value>, Option<Location>), AssignError>
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.
Sourcepub fn make_read_only(&mut self, location: Location)
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.
Methods from Deref<Target = Variable>§
Sourcepub fn is_read_only(&self) -> bool
pub fn is_read_only(&self) -> bool
Whether this variable is read-only or not.
Sourcepub fn expand(&self, location: &Location) -> Expansion<'_>
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>
impl<'a> Debug for VariableRefMut<'a>
Source§impl Deref for VariableRefMut<'_>
impl Deref for VariableRefMut<'_>
Source§impl<'a> From<&'a mut Variable> for VariableRefMut<'a>
impl<'a> From<&'a mut Variable> for VariableRefMut<'a>
Source§impl<'a> PartialEq for VariableRefMut<'a>
impl<'a> PartialEq for VariableRefMut<'a>
impl<'a> Eq for VariableRefMut<'a>
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> 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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