Skip to main content

FusedPattern

Enum FusedPattern 

Source
pub enum FusedPattern<'a> {
    RangeSum {
        start: Option<&'a Node>,
        end: &'a Node,
    },
}
Expand description

A high-level fusion pattern recognised at the AST level. Each variant borrows the relevant sub-expressions straight off the AST so consumers can re-evaluate / re-lower them in their own context (interpreter scope or IR LowerCtx).

Variants§

§

RangeSum

list.sum(range(end)) or list.sum(range(start, end)) with no intervening .map(...) / .filter(...) stages.

Equivalent fused semantics (the byte-exact contract every back-end and the interpreter must honour):

acc: i64 = 0
for i in start..end {        // empty when start >= end
    acc = acc.checked_add(i)?   // NumericOverflow on overflow
}
result = Int(acc)

This is a fusion (drop the intermediate Vec<Value> allocation), not a closed-form substitution: the same additions happen in the same order with the same checked-overflow behaviour as [start, .., end-1].sum() — the first overflowing partial sum raises NumericOverflow. start defaults to 0 for the one-arg range(end) form.

Fields

§start: Option<&'a Node>

start argument node when range(start, end); None for the one-arg range(end) form (implicit start = 0).

§end: &'a Node

end argument node — always present.

Trait Implementations§

Source§

impl<'a> Debug for FusedPattern<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for FusedPattern<'a>

§

impl<'a> RefUnwindSafe for FusedPattern<'a>

§

impl<'a> Send for FusedPattern<'a>

§

impl<'a> Sync for FusedPattern<'a>

§

impl<'a> Unpin for FusedPattern<'a>

§

impl<'a> UnsafeUnpin for FusedPattern<'a>

§

impl<'a> UnwindSafe for FusedPattern<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.