pub enum IrPat {
Wild,
Bind {
local: String,
},
Const {
value: ConstVal,
},
Variant {
scrutinee_ty: TyId,
tag: String,
fields: Vec<(String, Box<IrPat>)>,
},
Refined {
inner: Box<IrPat>,
refinement: Refinement,
},
Or {
alts: Vec<IrPat>,
},
}Expand description
P6.4’s real Pattern IR (design/bynk-greenfield-compiler.md §5.1, #1157):
a pattern’s own recursive shape, six variants mapping one-to-one onto
bynk_syntax::ast::Pattern’s own six (Wildcard, Binding, Literal,
Variant, Refined, Or). bynk_lower::lower_pattern_ir is the
&Pattern -> IrPat constructor, tested standalone — not yet wired into
IrExprKind::Match/Question/Is construction (P6.5’s own
commission). No PatId arena — a pattern owns its children directly
(Box<IrPat>), the same “no arena exists in this codebase” substitution
this module’s own doc comment already applies throughout.
Variants§
Wild
_ — matches anything, binds nothing.
Bind
A name binding — matches anything, binds local to the whole value
at this position (Decision B substitution: String, no LocalId
arena).
Const
A literal pattern — Int/Str/Bool only (ADR 0001’s closed
literal-pattern set), reusing ConstVal rather than inventing a
narrower value type for the variants (Float/DurationMillis/
Unit) no Pattern::Literal ever produces.
Variant
A sum-variant pattern, Variant or Variant(bindings) — not just a
user-declared sum (Decision A): scrutinee_ty is resolved through
the checker’s own variants_of, the same function that already
flattens a user sum, Result, Option, ActorSum and HttpResult
into one uniform shape, rather than Callee::Ctor’s
Arc<TypeDecl>-keyed identity scheme, which never fires for
Ok/Err/Some/None at all (#1145’s own Decision B) —
IrExprKind::Variant later resolved the identical problem on the
construction side the same way, #1225’s own ADR.
Fields
scrutinee_ty: TyIdThe value this pattern matches against — resolved via
variants_of(scrutinee_ty, ..) to find tag’s own payload
shape. Not the sum’s own declaration identity: no Arc<TypeDecl>
exists for a built-in sum like Option/Result.
fields: Vec<(String, Box<IrPat>)>Exactly the payload bindings the source pattern names — a named
form may bind a strict subset of the variant’s payload fields
(bynk-check’s own check_pattern allows this); empty for a
nullary pattern, even over a non-nullary variant (Miss without
(..) binds nothing and only tests the tag).
Refined
p 'where' predicate — R5.4: a refinement is a test, ordered after
structural matching and before the guard; never a binding site of its
own.
Or
p1 | p2 | … | pn — matches if any alternative matches. R5.5’s own
binding-mode consequence lives on IrArm::binding_mode, not here —
an Or node is a pure structural fact about the pattern’s shape.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IrPat
impl RefUnwindSafe for IrPat
impl Send for IrPat
impl Sync for IrPat
impl Unpin for IrPat
impl UnsafeUnpin for IrPat
impl UnwindSafe for IrPat
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,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§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();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§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();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§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();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§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();§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.§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);