pub enum Expr {
Show 65 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,
type_args: Option<Vec<TypeExpr>>,
args: Vec<Expr>,
},
Field {
expr: Box<Expr>,
field: Ident,
},
Index {
expr: Box<Expr>,
index: Box<Expr>,
},
Array(Vec<Expr>),
ArrayRepeat {
value: Box<Expr>,
count: Box<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 {
label: Option<Ident>,
body: Block,
},
While {
label: Option<Ident>,
condition: Box<Expr>,
body: Block,
},
For {
label: Option<Ident>,
pattern: Pattern,
iter: Box<Expr>,
body: Block,
},
Closure {
params: Vec<ClosureParam>,
return_type: Option<TypeExpr>,
body: Box<Expr>,
is_move: bool,
},
Await {
expr: Box<Expr>,
evidentiality: Option<Evidentiality>,
},
Try(Box<Expr>),
Return(Option<Box<Expr>>),
Break {
label: Option<Ident>,
value: Option<Box<Expr>>,
},
Continue {
label: Option<Ident>,
},
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>,
},
Let {
pattern: Pattern,
value: Box<Expr>,
},
Unsafe(Block),
Async {
block: Block,
is_move: bool,
},
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>>,
},
LegionFieldVar {
name: Ident,
},
LegionSuperposition {
field: Box<Expr>,
pattern: Box<Expr>,
},
LegionInterference {
query: Box<Expr>,
field: Box<Expr>,
},
LegionResonance {
expr: Box<Expr>,
},
LegionDistribute {
task: Box<Expr>,
count: Box<Expr>,
},
LegionGather {
fragments: Box<Expr>,
},
LegionBroadcast {
signal: Box<Expr>,
target: Box<Expr>,
},
LegionConsensus {
contributions: Box<Expr>,
},
LegionDecay {
field: Box<Expr>,
rate: Box<Expr>,
},
NamedArg {
name: Ident,
value: 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
Fields
Field
Field access
Index
Index: arr[i]
Array(Vec<Expr>)
Array literal
ArrayRepeat
Array repeat literal: [value; count]
Tuple(Vec<Expr>)
Tuple literal
Struct
Struct literal
Block(Block)
Block expression
If
If expression
Match
Match expression
Loop
Loop with optional label: 'label: loop { ... }
While
While loop with optional label: 'label: while cond { ... }
For
For loop with optional label: 'label: for x in iter { ... }
Closure
Closure: {x => x + 1} or |x| x + 1 or move |x| x + 1 or |x| -> T { ... }
Fields
params: Vec<ClosureParam>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
Break with optional label and value: break 'label value
Continue
Continue with optional label: continue 'label
Range
Range: a..b or a..=b
Macro
Macro invocation
Evidential
With evidentiality marker
Assign
Assignment: x = value
Let
Let expression (for if-let, while-let patterns): let pattern = expr
Unsafe(Block)
Unsafe block: unsafe { ... }
Async
Async block: async { ... } or async move { ... }
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)
LegionFieldVar
Legion field variable: memory∿
The ∿ suffix indicates a LegionField collective memory type
LegionSuperposition
Superposition: field∿ ⊕= pattern
Pattern joins the collective memory
LegionInterference
Interference query: query ⫰ field∿
Query the collective memory via interference
LegionResonance
Resonance extraction: resonance~ |◉
Extract agreement peaks from interference pattern
LegionDistribute
Distribute: task ⟁ agent_count
Fragment task holographically across agents
LegionGather
Gather: fragments ⟀
Unify fragments via interference
LegionBroadcast
Broadcast: signal ↠ legion
Send signal to all agents
LegionConsensus
Consensus: contributions ⇢
Achieve consensus from multiple contributions
LegionDecay
Decay: field∿ ∂= rate
Apply decay to collective memory
NamedArg
Named argument in function call: name: value
Used in calls like stack(axis: 0) or func(x: 1, y: 2)
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> 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);