pub enum ExprKind {
Show 18 variants
Ident(Path),
Lookup {
base: Box<Expr>,
lookup: Lookup,
},
Literal(Literal),
Nested(Box<Expr>),
TypeAnnotation(TypeAnnotation),
Tuple(Vec<TupleField>),
Array(Vec<Expr>),
Variant(Variant),
Range(Range),
Binary(BinaryExpr),
Unary(UnaryExpr),
Call(Call),
Func(Box<Func>),
FuncShort(Box<FuncShort>),
FString(Vec<InterpolateItem>),
Match(Match),
If(If),
VarBinding(VarBinding),
}Variants§
Ident(Path)
Lookup
A lookup into an object by name or position. Currently, this includes only tuple field lookups, primarily by name.
Literal(Literal)
Nested(Box<Expr>)
TypeAnnotation(TypeAnnotation)
Tuple(Vec<TupleField>)
Array(Vec<Expr>)
Variant(Variant)
Range(Range)
Binary(BinaryExpr)
Unary(UnaryExpr)
Call(Call)
Func(Box<Func>)
FuncShort(Box<FuncShort>)
FString(Vec<InterpolateItem>)
Match(Match)
If(If)
VarBinding(VarBinding)
Implementations§
Source§impl ExprKind
impl ExprKind
Sourcepub fn as_ident_mut(&mut self) -> Option<&mut Path>
pub fn as_ident_mut(&mut self) -> Option<&mut Path>
Optionally returns mutable references to the inner fields if this is a ExprKind::Ident, otherwise None
Sourcepub fn as_ident(&self) -> Option<&Path>
pub fn as_ident(&self) -> Option<&Path>
Optionally returns references to the inner fields if this is a ExprKind::Ident, otherwise None
Sourcepub fn into_ident(self) -> Result<Path, Self>
pub fn into_ident(self) -> Result<Path, Self>
Returns the inner fields if this is a ExprKind::Ident, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_lookup_mut(&mut self) -> Option<(&mut Box<Expr>, &mut Lookup)>
pub fn as_lookup_mut(&mut self) -> Option<(&mut Box<Expr>, &mut Lookup)>
Optionally returns mutable references to the inner fields if this is a ExprKind::Lookup, otherwise None
Sourcepub fn as_lookup(&self) -> Option<(&Box<Expr>, &Lookup)>
pub fn as_lookup(&self) -> Option<(&Box<Expr>, &Lookup)>
Optionally returns references to the inner fields if this is a ExprKind::Lookup, otherwise None
Sourcepub fn into_lookup(self) -> Result<(Box<Expr>, Lookup), Self>
pub fn into_lookup(self) -> Result<(Box<Expr>, Lookup), Self>
Returns the inner fields if this is a ExprKind::Lookup, otherwise returns back the enum in the Err case of the result
Sourcepub fn is_literal(&self) -> bool
pub fn is_literal(&self) -> bool
Returns true if this is a ExprKind::Literal, otherwise false
Sourcepub fn as_literal_mut(&mut self) -> Option<&mut Literal>
pub fn as_literal_mut(&mut self) -> Option<&mut Literal>
Optionally returns mutable references to the inner fields if this is a ExprKind::Literal, otherwise None
Sourcepub fn as_literal(&self) -> Option<&Literal>
pub fn as_literal(&self) -> Option<&Literal>
Optionally returns references to the inner fields if this is a ExprKind::Literal, otherwise None
Sourcepub fn into_literal(self) -> Result<Literal, Self>
pub fn into_literal(self) -> Result<Literal, Self>
Returns the inner fields if this is a ExprKind::Literal, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_nested_mut(&mut self) -> Option<&mut Box<Expr>>
pub fn as_nested_mut(&mut self) -> Option<&mut Box<Expr>>
Optionally returns mutable references to the inner fields if this is a ExprKind::Nested, otherwise None
Sourcepub fn as_nested(&self) -> Option<&Box<Expr>>
pub fn as_nested(&self) -> Option<&Box<Expr>>
Optionally returns references to the inner fields if this is a ExprKind::Nested, otherwise None
Sourcepub fn into_nested(self) -> Result<Box<Expr>, Self>
pub fn into_nested(self) -> Result<Box<Expr>, Self>
Returns the inner fields if this is a ExprKind::Nested, otherwise returns back the enum in the Err case of the result
Sourcepub fn is_type_annotation(&self) -> bool
pub fn is_type_annotation(&self) -> bool
Returns true if this is a ExprKind::TypeAnnotation, otherwise false
Sourcepub fn as_type_annotation_mut(&mut self) -> Option<&mut TypeAnnotation>
pub fn as_type_annotation_mut(&mut self) -> Option<&mut TypeAnnotation>
Optionally returns mutable references to the inner fields if this is a ExprKind::TypeAnnotation, otherwise None
Sourcepub fn as_type_annotation(&self) -> Option<&TypeAnnotation>
pub fn as_type_annotation(&self) -> Option<&TypeAnnotation>
Optionally returns references to the inner fields if this is a ExprKind::TypeAnnotation, otherwise None
Sourcepub fn into_type_annotation(self) -> Result<TypeAnnotation, Self>
pub fn into_type_annotation(self) -> Result<TypeAnnotation, Self>
Returns the inner fields if this is a ExprKind::TypeAnnotation, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_tuple_mut(&mut self) -> Option<&mut Vec<TupleField>>
pub fn as_tuple_mut(&mut self) -> Option<&mut Vec<TupleField>>
Optionally returns mutable references to the inner fields if this is a ExprKind::Tuple, otherwise None
Sourcepub fn as_tuple(&self) -> Option<&Vec<TupleField>>
pub fn as_tuple(&self) -> Option<&Vec<TupleField>>
Optionally returns references to the inner fields if this is a ExprKind::Tuple, otherwise None
Sourcepub fn into_tuple(self) -> Result<Vec<TupleField>, Self>
pub fn into_tuple(self) -> Result<Vec<TupleField>, Self>
Returns the inner fields if this is a ExprKind::Tuple, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Vec<Expr>>
pub fn as_array_mut(&mut self) -> Option<&mut Vec<Expr>>
Optionally returns mutable references to the inner fields if this is a ExprKind::Array, otherwise None
Sourcepub fn as_array(&self) -> Option<&Vec<Expr>>
pub fn as_array(&self) -> Option<&Vec<Expr>>
Optionally returns references to the inner fields if this is a ExprKind::Array, otherwise None
Sourcepub fn into_array(self) -> Result<Vec<Expr>, Self>
pub fn into_array(self) -> Result<Vec<Expr>, Self>
Returns the inner fields if this is a ExprKind::Array, otherwise returns back the enum in the Err case of the result
Sourcepub fn is_variant(&self) -> bool
pub fn is_variant(&self) -> bool
Returns true if this is a ExprKind::Variant, otherwise false
Sourcepub fn as_variant_mut(&mut self) -> Option<&mut Variant>
pub fn as_variant_mut(&mut self) -> Option<&mut Variant>
Optionally returns mutable references to the inner fields if this is a ExprKind::Variant, otherwise None
Sourcepub fn as_variant(&self) -> Option<&Variant>
pub fn as_variant(&self) -> Option<&Variant>
Optionally returns references to the inner fields if this is a ExprKind::Variant, otherwise None
Sourcepub fn into_variant(self) -> Result<Variant, Self>
pub fn into_variant(self) -> Result<Variant, Self>
Returns the inner fields if this is a ExprKind::Variant, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_range_mut(&mut self) -> Option<&mut Range>
pub fn as_range_mut(&mut self) -> Option<&mut Range>
Optionally returns mutable references to the inner fields if this is a ExprKind::Range, otherwise None
Sourcepub fn as_range(&self) -> Option<&Range>
pub fn as_range(&self) -> Option<&Range>
Optionally returns references to the inner fields if this is a ExprKind::Range, otherwise None
Sourcepub fn into_range(self) -> Result<Range, Self>
pub fn into_range(self) -> Result<Range, Self>
Returns the inner fields if this is a ExprKind::Range, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_binary_mut(&mut self) -> Option<&mut BinaryExpr>
pub fn as_binary_mut(&mut self) -> Option<&mut BinaryExpr>
Optionally returns mutable references to the inner fields if this is a ExprKind::Binary, otherwise None
Sourcepub fn as_binary(&self) -> Option<&BinaryExpr>
pub fn as_binary(&self) -> Option<&BinaryExpr>
Optionally returns references to the inner fields if this is a ExprKind::Binary, otherwise None
Sourcepub fn into_binary(self) -> Result<BinaryExpr, Self>
pub fn into_binary(self) -> Result<BinaryExpr, Self>
Returns the inner fields if this is a ExprKind::Binary, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_unary_mut(&mut self) -> Option<&mut UnaryExpr>
pub fn as_unary_mut(&mut self) -> Option<&mut UnaryExpr>
Optionally returns mutable references to the inner fields if this is a ExprKind::Unary, otherwise None
Sourcepub fn as_unary(&self) -> Option<&UnaryExpr>
pub fn as_unary(&self) -> Option<&UnaryExpr>
Optionally returns references to the inner fields if this is a ExprKind::Unary, otherwise None
Sourcepub fn into_unary(self) -> Result<UnaryExpr, Self>
pub fn into_unary(self) -> Result<UnaryExpr, Self>
Returns the inner fields if this is a ExprKind::Unary, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_call_mut(&mut self) -> Option<&mut Call>
pub fn as_call_mut(&mut self) -> Option<&mut Call>
Optionally returns mutable references to the inner fields if this is a ExprKind::Call, otherwise None
Sourcepub fn as_call(&self) -> Option<&Call>
pub fn as_call(&self) -> Option<&Call>
Optionally returns references to the inner fields if this is a ExprKind::Call, otherwise None
Sourcepub fn into_call(self) -> Result<Call, Self>
pub fn into_call(self) -> Result<Call, Self>
Returns the inner fields if this is a ExprKind::Call, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_func_mut(&mut self) -> Option<&mut Box<Func>>
pub fn as_func_mut(&mut self) -> Option<&mut Box<Func>>
Optionally returns mutable references to the inner fields if this is a ExprKind::Func, otherwise None
Sourcepub fn as_func(&self) -> Option<&Box<Func>>
pub fn as_func(&self) -> Option<&Box<Func>>
Optionally returns references to the inner fields if this is a ExprKind::Func, otherwise None
Sourcepub fn into_func(self) -> Result<Box<Func>, Self>
pub fn into_func(self) -> Result<Box<Func>, Self>
Returns the inner fields if this is a ExprKind::Func, otherwise returns back the enum in the Err case of the result
Sourcepub fn is_func_short(&self) -> bool
pub fn is_func_short(&self) -> bool
Returns true if this is a ExprKind::FuncShort, otherwise false
Sourcepub fn as_func_short_mut(&mut self) -> Option<&mut Box<FuncShort>>
pub fn as_func_short_mut(&mut self) -> Option<&mut Box<FuncShort>>
Optionally returns mutable references to the inner fields if this is a ExprKind::FuncShort, otherwise None
Sourcepub fn as_func_short(&self) -> Option<&Box<FuncShort>>
pub fn as_func_short(&self) -> Option<&Box<FuncShort>>
Optionally returns references to the inner fields if this is a ExprKind::FuncShort, otherwise None
Sourcepub fn into_func_short(self) -> Result<Box<FuncShort>, Self>
pub fn into_func_short(self) -> Result<Box<FuncShort>, Self>
Returns the inner fields if this is a ExprKind::FuncShort, otherwise returns back the enum in the Err case of the result
Sourcepub fn is_f_string(&self) -> bool
pub fn is_f_string(&self) -> bool
Returns true if this is a ExprKind::FString, otherwise false
Sourcepub fn as_f_string_mut(&mut self) -> Option<&mut Vec<InterpolateItem>>
pub fn as_f_string_mut(&mut self) -> Option<&mut Vec<InterpolateItem>>
Optionally returns mutable references to the inner fields if this is a ExprKind::FString, otherwise None
Sourcepub fn as_f_string(&self) -> Option<&Vec<InterpolateItem>>
pub fn as_f_string(&self) -> Option<&Vec<InterpolateItem>>
Optionally returns references to the inner fields if this is a ExprKind::FString, otherwise None
Sourcepub fn into_f_string(self) -> Result<Vec<InterpolateItem>, Self>
pub fn into_f_string(self) -> Result<Vec<InterpolateItem>, Self>
Returns the inner fields if this is a ExprKind::FString, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_match_mut(&mut self) -> Option<&mut Match>
pub fn as_match_mut(&mut self) -> Option<&mut Match>
Optionally returns mutable references to the inner fields if this is a ExprKind::Match, otherwise None
Sourcepub fn as_match(&self) -> Option<&Match>
pub fn as_match(&self) -> Option<&Match>
Optionally returns references to the inner fields if this is a ExprKind::Match, otherwise None
Sourcepub fn into_match(self) -> Result<Match, Self>
pub fn into_match(self) -> Result<Match, Self>
Returns the inner fields if this is a ExprKind::Match, otherwise returns back the enum in the Err case of the result
Sourcepub fn as_if_mut(&mut self) -> Option<&mut If>
pub fn as_if_mut(&mut self) -> Option<&mut If>
Optionally returns mutable references to the inner fields if this is a ExprKind::If, otherwise None
Sourcepub fn as_if(&self) -> Option<&If>
pub fn as_if(&self) -> Option<&If>
Optionally returns references to the inner fields if this is a ExprKind::If, otherwise None
Sourcepub fn into_if(self) -> Result<If, Self>
pub fn into_if(self) -> Result<If, Self>
Returns the inner fields if this is a ExprKind::If, otherwise returns back the enum in the Err case of the result
Sourcepub fn is_var_binding(&self) -> bool
pub fn is_var_binding(&self) -> bool
Returns true if this is a ExprKind::VarBinding, otherwise false
Sourcepub fn as_var_binding_mut(&mut self) -> Option<&mut VarBinding>
pub fn as_var_binding_mut(&mut self) -> Option<&mut VarBinding>
Optionally returns mutable references to the inner fields if this is a ExprKind::VarBinding, otherwise None
Sourcepub fn as_var_binding(&self) -> Option<&VarBinding>
pub fn as_var_binding(&self) -> Option<&VarBinding>
Optionally returns references to the inner fields if this is a ExprKind::VarBinding, otherwise None
Sourcepub fn into_var_binding(self) -> Result<VarBinding, Self>
pub fn into_var_binding(self) -> Result<VarBinding, Self>
Returns the inner fields if this is a ExprKind::VarBinding, otherwise returns back the enum in the Err case of the result
Trait Implementations§
Source§impl From<TypeAnnotation> for ExprKind
impl From<TypeAnnotation> for ExprKind
Source§fn from(value: TypeAnnotation) -> Self
fn from(value: TypeAnnotation) -> Self
impl StructuralPartialEq for ExprKind
Auto Trait Implementations§
impl Freeze for ExprKind
impl RefUnwindSafe for ExprKind
impl Send for ExprKind
impl Sync for ExprKind
impl Unpin for ExprKind
impl UnsafeUnpin for ExprKind
impl UnwindSafe for ExprKind
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);