forge_fmt::solang_ext

Trait SafeUnwrap

Source
pub trait SafeUnwrap<T> {
    // Required methods
    fn safe_unwrap(&self) -> &T;
    fn safe_unwrap_mut(&mut self) -> &mut T;
}
Expand description

Trait implemented to unwrap optional parse tree items initially introduced in hyperledger/solang#1068.

Note that the methods of this trait should only be used on parse tree items’ fields, like [pt::VariableDefinition] or [pt::EventDefinition], where the name field is None only when an error occurred during parsing.

Required Methods§

Source

fn safe_unwrap(&self) -> &T

Source

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

Implementations on Foreign Types§

Source§

impl SafeUnwrap<Identifier> for Option<Identifier>

Source§

fn safe_unwrap(&self) -> &Identifier

Source§

fn safe_unwrap_mut(&mut self) -> &mut Identifier

Source§

impl SafeUnwrap<StringLiteral> for Option<StringLiteral>

Source§

fn safe_unwrap(&self) -> &StringLiteral

Source§

fn safe_unwrap_mut(&mut self) -> &mut StringLiteral

Implementors§