EntryMut

Enum EntryMut 

Source
pub enum EntryMut<'a> {
    Expr(&'a mut Expr),
    Value(&'a mut Value),
}
Expand description

A mutable reference to either an Expr or a Value within a composite structure.

This is the mutable counterpart to Entry, used for in-place modification of nested expressions or values.

§Examples

use toasty_core::stmt::{EntryMut, Expr, Value};

let mut expr = Expr::from(Value::from(42_i64));
let mut entry = EntryMut::from(&mut expr);
assert!(entry.is_expr());

Variants§

§

Expr(&'a mut Expr)

A mutable reference to an expression.

§

Value(&'a mut Value)

A mutable reference to a value.

Implementations§

Source§

impl EntryMut<'_>

Source

pub fn as_expr(&self) -> Option<&Expr>

Returns a reference to the contained expression, or None.

Source

pub fn as_expr_unwrap(&self) -> &Expr

Returns a reference to the contained expression, panicking if not an expression.

§Panics

Panics if this entry is not EntryMut::Expr.

Source

pub fn as_expr_mut(&mut self) -> Option<&mut Expr>

Returns a mutable reference to the contained expression, or None.

Source

pub fn as_expr_mut_unwrap(&mut self) -> &mut Expr

Returns a mutable reference to the contained expression, panicking if not an expression.

§Panics

Panics if this entry is not EntryMut::Expr.

Source

pub fn is_expr(&self) -> bool

Returns true if this entry holds an expression.

Source

pub fn is_statement(&self) -> bool

Returns true if this entry holds a statement expression.

Source

pub fn is_value(&self) -> bool

Returns true if this entry holds a concrete value.

Source

pub fn is_value_null(&self) -> bool

Returns true if this entry holds a null value.

Source

pub fn is_default(&self) -> bool

Returns true if this entry is Expr::Default.

Source

pub fn take(&mut self) -> Expr

Takes the contained expression or value, replacing it with a default.

Source

pub fn insert(&mut self, expr: Expr)

Replaces the contents of this entry with expr.

§Panics

Panics if this is a Value entry and expr is not Expr::Value.

Trait Implementations§

Source§

impl<'a> Debug for EntryMut<'a>

Source§

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

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

impl<'a> From<&'a mut Expr> for EntryMut<'a>

Source§

fn from(value: &'a mut Expr) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a mut Value> for EntryMut<'a>

Source§

fn from(value: &'a mut Value) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for EntryMut<'a>

§

impl<'a> RefUnwindSafe for EntryMut<'a>

§

impl<'a> Send for EntryMut<'a>

§

impl<'a> Sync for EntryMut<'a>

§

impl<'a> Unpin for EntryMut<'a>

§

impl<'a> !UnwindSafe for EntryMut<'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, 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.