Skip to main content

RangeData

Struct RangeData 

Source
pub struct RangeData {
    pub start: i64,
    pub end: i64,
    pub step: i64,
    pub inclusive: bool,
}
Expand description

Range value carrier — an inclusive-or-exclusive integer interval with step. Built by MakeRange from the surface syntax start..end (exclusive) and start..=end (inclusive); produced as a typed Arc<RangeData> slot labeled NativeKind::Ptr(HeapKind::Range).

Distinct from IteratorState. Range is a value with identity (r.start, r.end, r.contains(x), print(r) -> 0..10) — an IteratorState is a stateful pipeline with a cursor. The .iter() receiver method on Range converts a RangeData into a fresh IteratorState with IteratorSource::Range { start, end_exclusive, step }, where end_exclusive is end + step for inclusive ranges (so 0..=10 step 1 produces values 0..11). IteratorSource::Range already models the post-conversion shape (W13-iterator-state, ADR-006 §2.7.16); RangeData is the pre-iter receiver value.

Bounds storage. Today only i64 integer ranges are representable. The Option<i64> shape used by the deleted pre-bulldozer Range payload (open ranges ..end, start.., ..) is deliberately NOT modeled here: the surface syntax for open ranges still compiles via op_make_range pushing a PushNull for the missing side, but the SURFACE handler rejects them per the playbook’s surface-and-stop discipline (open ranges need an iterator-tier semantic for for i in 0.. infinite loops which is its own ADR follow-up). step is always positive — matching the pre-strict-typing 0..n Rust-shape semantics.

Fields§

§start: i64

Inclusive lower bound.

§end: i64

Upper bound. When inclusive == true, the value end itself is reachable; when inclusive == false, end is exclusive (the surface-syntax start..end shape).

§step: i64

Per-iteration increment. Always positive; defaults to 1 from the MakeRange opcode (the surface syntax has no step suffix today).

§inclusive: bool

Whether the upper bound is reachable (start..=end shape).

Implementations§

Source§

impl RangeData

Source

pub fn new(start: i64, end: i64, step: i64, inclusive: bool) -> Self

Construct a fresh range with the given bounds and step.

Source

pub fn exclusive(start: i64, end: i64) -> Self

Construct an exclusive range start..end with step 1 (matching the surface-syntax 0..n shape).

Source

pub fn inclusive(start: i64, end: i64) -> Self

Construct an inclusive range start..=end with step 1.

Source

pub fn end_exclusive(&self) -> i64

Effective exclusive end — end + step for inclusive ranges, end for exclusive ranges. Matches the upper bound used by IteratorSource::Range’s end field (which is exclusive by W13-iterator-state’s contract).

Source

pub fn len(&self) -> usize

Element count. Mirrors IteratorSource::Range::len so a range and its post-.iter() IteratorState report the same count. For non-positive step or an empty interval, returns 0.

Source

pub fn is_empty(&self) -> bool

Whether the range yields zero elements.

Source

pub fn contains(&self, value: i64) -> bool

Whether value falls within the range. The check is bound-aware (inclusive vs exclusive end) but does NOT enforce step alignment — (0..10).contains(5) is true regardless of step. This matches the pre-bulldozer surface-syntax shape: range.contains is a bound test, not a “would .iter() yield this exact value” probe.

Source

pub fn to_vec_i64(&self) -> Vec<i64>

Materialize the range into a Vec<i64> of every yielded value (mirror of .iter().collect() for the pre-bulldozer range.toArray() method shape). Empty range -> empty vec.

Trait Implementations§

Source§

impl Clone for RangeData

Source§

fn clone(&self) -> RangeData

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RangeData

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,