pub enum Expr {
Show 52 variants
Literal(Literal),
Path(TypePath),
Binary {
left: Box<Expr>,
op: BinOp,
right: Box<Expr>,
},
Unary {
op: UnaryOp,
expr: Box<Expr>,
},
Pipe {
expr: Box<Expr>,
operations: Vec<PipeOp>,
},
Incorporation {
segments: Vec<IncorporationSegment>,
},
Morpheme {
kind: MorphemeKind,
body: Box<Expr>,
},
Call {
func: Box<Expr>,
args: Vec<Expr>,
},
MethodCall {
receiver: Box<Expr>,
method: Ident,
args: Vec<Expr>,
},
Field {
expr: Box<Expr>,
field: Ident,
},
Index {
expr: Box<Expr>,
index: Box<Expr>,
},
Array(Vec<Expr>),
Tuple(Vec<Expr>),
Struct {
path: TypePath,
fields: Vec<FieldInit>,
rest: Option<Box<Expr>>,
},
Block(Block),
If {
condition: Box<Expr>,
then_branch: Block,
else_branch: Option<Box<Expr>>,
},
Match {
expr: Box<Expr>,
arms: Vec<MatchArm>,
},
Loop(Block),
While {
condition: Box<Expr>,
body: Block,
},
For {
pattern: Pattern,
iter: Box<Expr>,
body: Block,
},
Closure {
params: Vec<ClosureParam>,
body: Box<Expr>,
},
Await {
expr: Box<Expr>,
evidentiality: Option<Evidentiality>,
},
Try(Box<Expr>),
Return(Option<Box<Expr>>),
Break(Option<Box<Expr>>),
Continue,
Range {
start: Option<Box<Expr>>,
end: Option<Box<Expr>>,
inclusive: bool,
},
Macro {
path: TypePath,
tokens: String,
},
Evidential {
expr: Box<Expr>,
evidentiality: Evidentiality,
},
Assign {
target: Box<Expr>,
value: Box<Expr>,
},
Unsafe(Block),
Deref(Box<Expr>),
AddrOf {
mutable: bool,
expr: Box<Expr>,
},
Cast {
expr: Box<Expr>,
ty: TypeExpr,
},
InlineAsm(InlineAsm),
VolatileRead {
ptr: Box<Expr>,
ty: Option<TypeExpr>,
},
VolatileWrite {
ptr: Box<Expr>,
value: Box<Expr>,
ty: Option<TypeExpr>,
},
SimdLiteral {
elements: Vec<Expr>,
ty: Option<TypeExpr>,
},
SimdIntrinsic {
op: SimdOp,
args: Vec<Expr>,
},
SimdShuffle {
a: Box<Expr>,
b: Box<Expr>,
indices: Vec<u8>,
},
SimdSplat {
value: Box<Expr>,
lanes: u8,
},
SimdExtract {
vector: Box<Expr>,
index: u8,
},
SimdInsert {
vector: Box<Expr>,
index: u8,
value: Box<Expr>,
},
AtomicOp {
op: AtomicOp,
ptr: Box<Expr>,
value: Option<Box<Expr>>,
expected: Option<Box<Expr>>,
ordering: MemoryOrdering,
failure_ordering: Option<MemoryOrdering>,
},
AtomicFence {
ordering: MemoryOrdering,
},
HttpRequest {
method: HttpMethod,
url: Box<Expr>,
headers: Vec<(Expr, Expr)>,
body: Option<Box<Expr>>,
timeout: Option<Box<Expr>>,
},
GrpcCall {
service: Box<Expr>,
method: Box<Expr>,
message: Option<Box<Expr>>,
metadata: Vec<(Expr, Expr)>,
timeout: Option<Box<Expr>>,
},
WebSocketConnect {
url: Box<Expr>,
protocols: Vec<Expr>,
headers: Vec<(Expr, Expr)>,
},
WebSocketMessage {
kind: WebSocketMessageKind,
data: Box<Expr>,
},
KafkaOp {
kind: KafkaOpKind,
topic: Box<Expr>,
payload: Option<Box<Expr>>,
key: Option<Box<Expr>>,
partition: Option<Box<Expr>>,
},
GraphQLOp {
kind: GraphQLOpKind,
document: Box<Expr>,
variables: Option<Box<Expr>>,
operation_name: Option<Box<Expr>>,
},
ProtocolStream {
protocol: ProtocolKind,
source: Box<Expr>,
config: Option<Box<Expr>>,
},
}Expand description
Expressions.
Variants§
Literal(Literal)
Literal value
Path(TypePath)
Variable reference
Binary
Binary operation
Unary
Unary operation
Pipe
Pipe expression: x|f|g
Incorporation
Incorporation: file·open·read
Fields
segments: Vec<IncorporationSegment>Morpheme
Morpheme application: τ{f}
Call
Function call
MethodCall
Method call
Field
Field access
Index
Index: arr[i]
Array(Vec<Expr>)
Array literal
Tuple(Vec<Expr>)
Tuple literal
Struct
Struct literal
Block(Block)
Block expression
If
If expression
Match
Match expression
Loop(Block)
Loop
While
While loop
For
For loop
Closure
Closure: {x => x + 1} or |x| x + 1
Await
Await with optional evidentiality: expr⌛ or expr⌛? or expr⌛! or expr⌛~
The evidentiality marker specifies how to handle the awaited result:
⌛?- await and propagate error (uncertain)⌛!- await, expect success (known/infallible)⌛~- await external/reported source⌛‽- await with trust boundary crossing
Try(Box<Expr>)
Try: expr?
Return(Option<Box<Expr>>)
Return
Break(Option<Box<Expr>>)
Break
Continue
Continue
Range
Range: a..b or a..=b
Macro
Macro invocation
Evidential
With evidentiality marker
Assign
Assignment: x = value
Unsafe(Block)
Unsafe block: unsafe { ... }
Deref(Box<Expr>)
Raw pointer dereference: *ptr
AddrOf
Address-of: &expr or &mut expr
Cast
Cast: expr as Type
InlineAsm(InlineAsm)
Inline assembly: asm!("instruction", ...)
VolatileRead
Volatile read: volatile read<T>(ptr) or volatile read(ptr)
VolatileWrite
Volatile write: volatile write<T>(ptr, value) or volatile write(ptr, value)
SimdLiteral
SIMD vector literal: simd[1.0, 2.0, 3.0, 4.0]
SimdIntrinsic
SIMD intrinsic operation: simd::add(a, b)
SimdShuffle
SIMD shuffle: simd::shuffle(a, b, [0, 4, 1, 5])
SimdSplat
SIMD splat (broadcast scalar to all lanes): simd::splat(x)
SimdExtract
SIMD extract single lane: simd::extract(v, 0)
SimdInsert
SIMD insert into lane: simd::insert(v, 0, value)
AtomicOp
Atomic operation: atomic::load(&x, Ordering::SeqCst)
AtomicFence
Atomic fence: atomic::fence(Ordering::SeqCst)
Fields
ordering: MemoryOrderingHttpRequest
HTTP request: http·get(url), http·post(url), etc.
Incorporation pattern for building HTTP requests
Fields
method: HttpMethodGrpcCall
gRPC call: grpc·call(service, method)
Incorporation pattern for gRPC operations
Fields
WebSocketConnect
WebSocket connection: ws·connect(url)
Incorporation pattern for WebSocket operations
WebSocketMessage
WebSocket message: ws·message(data) or ws·text(str) / ws·binary(bytes)
KafkaOp
Kafka operation: kafka·produce(topic, message), kafka·consume(topic)
Fields
kind: KafkaOpKindGraphQLOp
GraphQL query: graphql·query(document) or graphql·mutation(document)
Fields
kind: GraphQLOpKindProtocolStream
Protocol stream: iterable over network messages
http·stream(url), ws·stream(), kafka·stream(topic)
Trait Implementations§
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnwindSafe for Expr
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> 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);