arcis 0.13.1

A standard library of types and functions for writing MPC circuits with the Arcis framework.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
//! Operator overloading traits and range types accepted by the arcis interpreter.
//!
//! The traits in this module are documentation-only handles: they exist so
//! rustdoc renders a page per trait, with an auto-generated implementors list
//! showing which types the arcis interpreter recognizes the operator on.
//!
//! # Range types
//!
//! [`Range`], [`RangeInclusive`], [`RangeFrom`], [`RangeTo`], [`RangeToInclusive`],
//! and [`RangeFull`] are doc-only redefinitions of their [`std::ops`] counterparts.
//! Users write the syntax (`a..b`, `a..=b`, `a..`, `..b`, `..=b`, `..`) and the
//! interpreter constructs the appropriate value. See each type for iteration
//! capabilities and slice-indexing semantics.
//!
//! # Implementing
//!
//! Every trait in this module is **neither derivable nor implementable**
//! inside `#[encrypted]` code. The interpreter dispatches the corresponding
//! operator directly on the types listed below; there is no way to extend
//! that set from user code today. This may be revisited in a future PR.
//!
//! # Calling
//!
//! Only the operator form is accepted (e.g. `a + b`). The trait methods
//! (`.add(b)`, `Add::add(&a, &b)`, `<T as Add>::add(&a, &b)`) and the
//! associated types (e.g. `<T as Add>::Output`) are **not** accepted.
//!
//! Each trait in this module is a thin mirror of the same-named trait in
//! [`std::ops`].
//!
//! # Shift operators
//!
//! For [`Shl`] and [`Shr`], the right-hand side must be a **compile-time
//! known** value (a literal, a `const`, or anything else the interpreter can
//! resolve at lowering time). A shift by a runtime-determined amount is not
//! accepted.

// =================== Add / Sub / Mul / Div / Rem ===================
//
// Arithmetic-impl coverage differs by op:
//
// * `Add`, `Sub`, `Mul` (and their assigns) work on integers, floats, and `BaseField25519`.
// * `Div` (and `DivAssign`) work on integers and floats only. `BaseField25519` has no `/` impl —
//   use [`crate::BaseField25519::field_division`] or [`crate::BaseField25519::euclidean_division`]
//   instead.
// * `Rem` (and `RemAssign`) work on integers only. There is no `%` on floats or on
//   `BaseField25519`.

macro_rules! impl_for_integers {
    ($trait:ident) => {
        impl $trait for crate::std::integer::u8 {}
        impl $trait for crate::std::integer::u16 {}
        impl $trait for crate::std::integer::u32 {}
        impl $trait for crate::std::integer::u64 {}
        impl $trait for crate::std::integer::u128 {}
        impl $trait for crate::std::integer::usize {}

        impl $trait for crate::std::integer::i8 {}
        impl $trait for crate::std::integer::i16 {}
        impl $trait for crate::std::integer::i32 {}
        impl $trait for crate::std::integer::i64 {}
        impl $trait for crate::std::integer::i128 {}
        impl $trait for crate::std::integer::isize {}
    };
}

macro_rules! impl_for_integers_and_floats {
    ($trait:ident) => {
        impl_for_integers!($trait);
        impl $trait for crate::std::float::f32 {}
        impl $trait for crate::std::float::f64 {}
    };
}

macro_rules! impl_for_integers_floats_and_basefield {
    ($trait:ident) => {
        impl_for_integers_and_floats!($trait);
        impl $trait for crate::BaseField25519 {}
    };
}

/// Addition operator `+`. Mirrors [`std::ops::Add`].
///
/// Use `+` directly; the methods (`.add(b)`, `Add::add(&a, &b)`, `<T as Add>::add(&a, &b)`)
/// and the associated type `<T as Add>::Output` are not accepted.
pub trait Add {}
impl_for_integers_floats_and_basefield!(Add);

/// Subtraction operator `-`. Mirrors [`std::ops::Sub`].
///
/// Use `-` directly; the methods (`.sub(b)`, `Sub::sub(&a, &b)`, `<T as Sub>::sub(&a, &b)`)
/// and the associated type `<T as Sub>::Output` are not accepted.
pub trait Sub {}
impl_for_integers_floats_and_basefield!(Sub);

/// Multiplication operator `*`. Mirrors [`std::ops::Mul`].
///
/// Use `*` directly; the methods (`.mul(b)`, `Mul::mul(&a, &b)`, `<T as Mul>::mul(&a, &b)`)
/// and the associated type `<T as Mul>::Output` are not accepted.
pub trait Mul {}
impl_for_integers_floats_and_basefield!(Mul);

/// Division operator `/`. Mirrors [`std::ops::Div`].
///
/// `BaseField25519` does **not** implement `/`. Use
/// [`crate::BaseField25519::field_division`] or
/// [`crate::BaseField25519::euclidean_division`] instead.
///
/// Use `/` directly; the methods (`.div(b)`, `Div::div(&a, &b)`, `<T as Div>::div(&a, &b)`)
/// and the associated type `<T as Div>::Output` are not accepted.
pub trait Div {}
impl_for_integers_and_floats!(Div);

/// Remainder operator `%`. Mirrors [`std::ops::Rem`].
///
/// Integers only — there is no `%` on floats or on `BaseField25519`.
///
/// Use `%` directly; the methods (`.rem(b)`, `Rem::rem(&a, &b)`, `<T as Rem>::rem(&a, &b)`)
/// and the associated type `<T as Rem>::Output` are not accepted.
pub trait Rem {}
impl_for_integers!(Rem);

/// Compound assignment `+=`. Mirrors [`std::ops::AddAssign`].
///
/// Use `+=` directly; `.add_assign(b)`, `AddAssign::add_assign(&mut a, b)`, and
/// `<T as AddAssign>::add_assign(&mut a, b)` are not accepted.
pub trait AddAssign {}
impl_for_integers_floats_and_basefield!(AddAssign);

/// Compound assignment `-=`. Mirrors [`std::ops::SubAssign`].
///
/// Use `-=` directly; `.sub_assign(b)`, `SubAssign::sub_assign(&mut a, b)`, and
/// `<T as SubAssign>::sub_assign(&mut a, b)` are not accepted.
pub trait SubAssign {}
impl_for_integers_floats_and_basefield!(SubAssign);

/// Compound assignment `*=`. Mirrors [`std::ops::MulAssign`].
///
/// Use `*=` directly; `.mul_assign(b)`, `MulAssign::mul_assign(&mut a, b)`, and
/// `<T as MulAssign>::mul_assign(&mut a, b)` are not accepted.
pub trait MulAssign {}
impl_for_integers_floats_and_basefield!(MulAssign);

/// Compound assignment `/=`. Mirrors [`std::ops::DivAssign`].
///
/// See [`Div`] for the BaseField caveat.
///
/// Use `/=` directly; `.div_assign(b)`, `DivAssign::div_assign(&mut a, b)`, and
/// `<T as DivAssign>::div_assign(&mut a, b)` are not accepted.
pub trait DivAssign {}
impl_for_integers_and_floats!(DivAssign);

/// Compound assignment `%=`. Mirrors [`std::ops::RemAssign`].
///
/// Integers only.
///
/// Use `%=` directly; `.rem_assign(b)`, `RemAssign::rem_assign(&mut a, b)`, and
/// `<T as RemAssign>::rem_assign(&mut a, b)` are not accepted.
pub trait RemAssign {}
impl_for_integers!(RemAssign);

// =================== Neg ===================

/// Unary negation operator `-`. Mirrors [`std::ops::Neg`].
///
/// Use `-x` directly; the methods (`.neg()`, `Neg::neg(x)`, `<T as Neg>::neg(x)`)
/// and the associated type `<T as Neg>::Output` are not accepted.
pub trait Neg {}

impl Neg for crate::std::integer::i8 {}
impl Neg for crate::std::integer::i16 {}
impl Neg for crate::std::integer::i32 {}
impl Neg for crate::std::integer::i64 {}
impl Neg for crate::std::integer::i128 {}
impl Neg for crate::std::integer::isize {}

impl Neg for crate::std::float::f32 {}
impl Neg for crate::std::float::f64 {}

impl Neg for crate::BaseField25519 {}

// =================== Not ===================

/// Unary `!` operator. Mirrors [`std::ops::Not`].
///
/// On [`bool`](crate::std::boolean::bool) this is logical negation. On integer
/// types it is bitwise complement.
///
/// Use `!x` directly; the methods (`.not()`, `Not::not(x)`, `<T as Not>::not(x)`)
/// and the associated type `<T as Not>::Output` are not accepted.
pub trait Not {}

impl Not for crate::std::boolean::bool {}

impl Not for crate::std::integer::u8 {}
impl Not for crate::std::integer::u16 {}
impl Not for crate::std::integer::u32 {}
impl Not for crate::std::integer::u64 {}
impl Not for crate::std::integer::u128 {}
impl Not for crate::std::integer::usize {}

impl Not for crate::std::integer::i8 {}
impl Not for crate::std::integer::i16 {}
impl Not for crate::std::integer::i32 {}
impl Not for crate::std::integer::i64 {}
impl Not for crate::std::integer::i128 {}
impl Not for crate::std::integer::isize {}

// =================== Bitwise ===================
//
// `&`, `|`, `^` (and their assigns) work on every integer type and on `bool`.
// Note: `&&` and `||` are short-circuit operators handled separately by the
// interpreter and do not go through `BitAnd` / `BitOr`.

macro_rules! impl_bit_for_integers_and_bool {
    ($trait:ident) => {
        impl $trait for crate::std::boolean::bool {}

        impl $trait for crate::std::integer::u8 {}
        impl $trait for crate::std::integer::u16 {}
        impl $trait for crate::std::integer::u32 {}
        impl $trait for crate::std::integer::u64 {}
        impl $trait for crate::std::integer::u128 {}
        impl $trait for crate::std::integer::usize {}

        impl $trait for crate::std::integer::i8 {}
        impl $trait for crate::std::integer::i16 {}
        impl $trait for crate::std::integer::i32 {}
        impl $trait for crate::std::integer::i64 {}
        impl $trait for crate::std::integer::i128 {}
        impl $trait for crate::std::integer::isize {}
    };
}

/// Bitwise / boolean `&`. Mirrors [`std::ops::BitAnd`].
///
/// Use `&` directly; the methods (`.bitand(b)`, `BitAnd::bitand(&a, &b)`,
/// `<T as BitAnd>::bitand(&a, &b)`) and the associated type `<T as BitAnd>::Output`
/// are not accepted.
pub trait BitAnd {}
impl_bit_for_integers_and_bool!(BitAnd);

/// Bitwise / boolean `|`. Mirrors [`std::ops::BitOr`].
///
/// Use `|` directly; the methods (`.bitor(b)`, `BitOr::bitor(&a, &b)`,
/// `<T as BitOr>::bitor(&a, &b)`) and the associated type `<T as BitOr>::Output`
/// are not accepted.
pub trait BitOr {}
impl_bit_for_integers_and_bool!(BitOr);

/// Bitwise / boolean `^`. Mirrors [`std::ops::BitXor`].
///
/// Use `^` directly; the methods (`.bitxor(b)`, `BitXor::bitxor(&a, &b)`,
/// `<T as BitXor>::bitxor(&a, &b)`) and the associated type `<T as BitXor>::Output`
/// are not accepted.
pub trait BitXor {}
impl_bit_for_integers_and_bool!(BitXor);

/// Compound assignment `&=`. Mirrors [`std::ops::BitAndAssign`].
///
/// Use `&=` directly; `.bitand_assign(b)`, `BitAndAssign::bitand_assign(&mut a, b)`, and
/// `<T as BitAndAssign>::bitand_assign(&mut a, b)` are not accepted.
pub trait BitAndAssign {}
impl_bit_for_integers_and_bool!(BitAndAssign);

/// Compound assignment `|=`. Mirrors [`std::ops::BitOrAssign`].
///
/// Use `|=` directly; `.bitor_assign(b)`, `BitOrAssign::bitor_assign(&mut a, b)`, and
/// `<T as BitOrAssign>::bitor_assign(&mut a, b)` are not accepted.
pub trait BitOrAssign {}
impl_bit_for_integers_and_bool!(BitOrAssign);

/// Compound assignment `^=`. Mirrors [`std::ops::BitXorAssign`].
///
/// Use `^=` directly; `.bitxor_assign(b)`, `BitXorAssign::bitxor_assign(&mut a, b)`, and
/// `<T as BitXorAssign>::bitxor_assign(&mut a, b)` are not accepted.
pub trait BitXorAssign {}
impl_bit_for_integers_and_bool!(BitXorAssign);

// =================== Shifts ===================
//
// The right-hand side of every shift must be **compile-time known** — a
// literal, a `const`, or anything else the interpreter resolves at lowering
// time. A shift by a runtime-determined amount is rejected.

// Per-impl helper: emits a single `impl` carrying the per-type compile-time
// caveat doc, so the note shows up next to the impl on the type's own page
// (e.g. `arcis::std::integer::u32`), not just on the trait page.
macro_rules! impl_shift {
    ($trait:ident, $ty:ty) => {
        /// Right-hand side must be **compile-time known**.
        impl $trait for $ty {}
    };
}

macro_rules! impl_shift_for_integers {
    ($trait:ident) => {
        impl_shift!($trait, crate::std::integer::u8);
        impl_shift!($trait, crate::std::integer::u16);
        impl_shift!($trait, crate::std::integer::u32);
        impl_shift!($trait, crate::std::integer::u64);
        impl_shift!($trait, crate::std::integer::u128);
        impl_shift!($trait, crate::std::integer::usize);

        impl_shift!($trait, crate::std::integer::i8);
        impl_shift!($trait, crate::std::integer::i16);
        impl_shift!($trait, crate::std::integer::i32);
        impl_shift!($trait, crate::std::integer::i64);
        impl_shift!($trait, crate::std::integer::i128);
        impl_shift!($trait, crate::std::integer::isize);
    };
}

/// Left-shift operator `<<`. Mirrors [`std::ops::Shl`].
///
/// The right-hand side must be **compile-time known**.
///
/// Use `<<` directly; the methods (`.shl(b)`, `Shl::shl(a, b)`, `<T as Shl>::shl(a, b)`)
/// and the associated type `<T as Shl>::Output` are not accepted.
pub trait Shl {}
impl_shift_for_integers!(Shl);

/// Right-shift operator `>>`. Mirrors [`std::ops::Shr`].
///
/// The right-hand side must be **compile-time known**.
///
/// Use `>>` directly; the methods (`.shr(b)`, `Shr::shr(a, b)`, `<T as Shr>::shr(a, b)`)
/// and the associated type `<T as Shr>::Output` are not accepted.
pub trait Shr {}
impl_shift_for_integers!(Shr);

/// Compound assignment `<<=`. Mirrors [`std::ops::ShlAssign`].
///
/// The right-hand side must be **compile-time known**.
///
/// Use `<<=` directly; `.shl_assign(b)`, `ShlAssign::shl_assign(&mut a, b)`, and
/// `<T as ShlAssign>::shl_assign(&mut a, b)` are not accepted.
pub trait ShlAssign {}
impl_shift_for_integers!(ShlAssign);

/// Compound assignment `>>=`. Mirrors [`std::ops::ShrAssign`].
///
/// The right-hand side must be **compile-time known**.
///
/// Use `>>=` directly; `.shr_assign(b)`, `ShrAssign::shr_assign(&mut a, b)`, and
/// `<T as ShrAssign>::shr_assign(&mut a, b)` are not accepted.
pub trait ShrAssign {}
impl_shift_for_integers!(ShrAssign);

// =================== Index / IndexMut ===================
//
// `a[i]` and `a[i] = …` work on arrays, slices, and `Box<[T]>`. The index `i`
// may be a `usize` (single element) or any of the range types in this module
// (slice).
//
// If the index is known at compile time, the access compiles to a direct
// reference. If it is determined at runtime, the access compiles to a circuit
// of size O(`a.len()`) — every element is conditionally selected.

macro_rules! impl_index_for_sequences {
    ($trait:ident) => {
        impl<T, const N: usize> $trait<crate::std::integer::usize> for [T; N] {}
        impl<T> $trait<crate::std::integer::usize> for [T] {}
        impl<T> $trait<crate::std::integer::usize> for crate::std::boxed::Box<[T]> {}
    };
}

/// Indexing operator `a[i]`. Mirrors [`std::ops::Index`].
///
/// Use the `a[i]` form directly; the method (`.index(i)`,
/// `Index::index(&a, i)`, `<T as Index<Idx>>::index(&a, i)`) and the
/// associated type `<T as Index<Idx>>::Output` are not accepted.
///
/// **Index types:**
///
/// * `usize` — single-element access.
/// * Any range type — yields a slice. Bounds that are specified must be compile-time known.
///   * [`Range<usize>`](Range), [`RangeInclusive<usize>`](RangeInclusive) — `arr[2..5]`,
///     `arr[2..=4]`.
///   * [`RangeFrom<usize>`](RangeFrom), [`RangeTo<usize>`](RangeTo),
///     [`RangeToInclusive<usize>`](RangeToInclusive) — `arr[2..]`, `arr[..5]`, `arr[..=4]`.
///   * [`RangeFull`] — `arr[..]` clones the whole array.
///
/// **Complexity:** if the index / range bounds are compile-time known, the
/// access compiles to a direct reference. If determined at runtime, the access
/// compiles to a circuit of size O(`a.len()`).
///
/// **Autoderef:** indexing through one or more layers of reference is accepted
/// (`(&arr)[0]`, `(&&arr)[0]`, …). Rust's method-call autoderef peels them
/// before reaching the `Index` impl, so the implementor list below only
/// mentions the underlying types.
pub trait Index<Idx> {}
impl_index_for_sequences!(Index);

/// Mutable indexing operator `a[i] = …`. Mirrors [`std::ops::IndexMut`].
///
/// Use the `a[i] = …` form (or `a[i] += …`, etc.) directly; the method forms
/// (`.index_mut(i)`, `IndexMut::index_mut(&mut a, i)`,
/// `<T as IndexMut<Idx>>::index_mut(&mut a, i)`) are not accepted.
///
/// Same constraints as [`Index`] for the index types, the runtime cost, and
/// autoderef.
pub trait IndexMut<Idx>: Index<Idx> {}
impl_index_for_sequences!(IndexMut);

// =================== Ranges ===================
//
// Each type mirrors the same-named type in [`std::ops`]. The interpreter
// constructs them from the corresponding range syntax; users typically don't
// spell the type name.
//
// **Iteration:**
// * [`Range`] (`a..b`), [`RangeInclusive`] (`a..=b`) — fully iterable.
// * [`RangeFrom`] (`a..`) — forward iteration works; anything requiring a total length (`.count()`,
//   `.rev()`, iterator adapters that need `.len()`) panics.
// * [`RangeTo`] (`..b`), [`RangeToInclusive`] (`..=b`), [`RangeFull`] (`..`) — not iterable; every
//   iterator method panics. Slice-indexing only.
//
// **Slice indexing:** all six work as slice indices (see [`Index`]).
//
// **Field visibility** follows [`std::ops`] — public fields where std has them,
// private fields on [`RangeInclusive`] with `.start()` / `.end()` accessors.

const RANGE_STUB_MSG: &str = "arcis::std::ops range types are documentation-only; \
    inside `#[encrypted]` code the interpreter intercepts real range \
    construction / iteration / slicing before these stubs run.";

/// A (half-open) range `start..end`. Mirrors [`std::ops::Range`].
///
/// Contains all values with `start <= x < end`; empty when `start >= end`.
///
/// Iterable — yields `start`, `start + 1`, …, `end - 1`.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Range<Idx> {
    /// The lower bound (inclusive).
    pub start: Idx,
    /// The upper bound (exclusive).
    pub end: Idx,
}

impl<Idx> Range<Idx> {
    /// Returns whether `t` lies in the range: `start <= t < end`.
    pub fn contains(&self, _t: Idx) -> bool {
        unimplemented!("{RANGE_STUB_MSG}")
    }
}

/// A closed range `start..=end`. Mirrors [`std::ops::RangeInclusive`].
///
/// Contains all values with `start <= x <= end`; empty when `start > end`.
///
/// Iterable — yields `start`, `start + 1`, …, `end`.
///
/// Fields are private (matching [`std::ops::RangeInclusive`]); use
/// [`Self::start`] and [`Self::end`] to read them.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RangeInclusive<Idx> {
    start: Idx,
    end: Idx,
}

impl<Idx> RangeInclusive<Idx> {
    /// Constructs a new `start..=end`.
    pub fn new(_start: Idx, _end: Idx) -> Self {
        unimplemented!("{RANGE_STUB_MSG}")
    }
    /// Returns a reference to the range's start.
    pub fn start(&self) -> &Idx {
        unimplemented!("{RANGE_STUB_MSG}")
    }
    /// Returns a reference to the range's end.
    pub fn end(&self) -> &Idx {
        unimplemented!("{RANGE_STUB_MSG}")
    }
    /// Returns whether `t` lies in the range: `start <= t <= end`.
    pub fn contains(&self, _t: Idx) -> bool {
        unimplemented!("{RANGE_STUB_MSG}")
    }
}

/// A range with only a lower bound: `start..`. Mirrors [`std::ops::RangeFrom`].
///
/// Forward iteration (`.next()`) yields `start`, `start + 1`, … indefinitely.
/// Any operation that needs the total length — `.count()`, `.rev()`, adapters
/// that require `.len()` — panics at interpret time because the length is
/// unbounded.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RangeFrom<Idx> {
    /// The lower bound (inclusive).
    pub start: Idx,
}

impl<Idx> RangeFrom<Idx> {
    /// Returns whether `t` lies in the range: `start <= t`.
    pub fn contains(&self, _t: Idx) -> bool {
        unimplemented!("{RANGE_STUB_MSG}")
    }
}

/// A range with only an exclusive upper bound: `..end`. Mirrors [`std::ops::RangeTo`].
///
/// Not iterable — every iterator method panics at interpret time. Use as a
/// slice index only.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RangeTo<Idx> {
    /// The upper bound (exclusive).
    pub end: Idx,
}

impl<Idx> RangeTo<Idx> {
    /// Returns whether `t` lies in the range: `t < end`.
    pub fn contains(&self, _t: Idx) -> bool {
        unimplemented!("{RANGE_STUB_MSG}")
    }
}

/// A range with only an inclusive upper bound: `..=end`. Mirrors
/// [`std::ops::RangeToInclusive`].
///
/// Not iterable — every iterator method panics at interpret time. Use as a
/// slice index only.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RangeToInclusive<Idx> {
    /// The upper bound (inclusive).
    pub end: Idx,
}

impl<Idx> RangeToInclusive<Idx> {
    /// Returns whether `t` lies in the range: `t <= end`.
    pub fn contains(&self, _t: Idx) -> bool {
        unimplemented!("{RANGE_STUB_MSG}")
    }
}

/// The unbounded range `..`. Mirrors [`std::ops::RangeFull`].
///
/// Not iterable — every iterator method panics at interpret time. Used mainly
/// as a slice index (`arr[..]` clones the whole array).
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct RangeFull;

impl RangeFull {
    /// Always `true` — every value is contained in the full range.
    pub fn contains<T>(&self, _t: T) -> bool {
        unimplemented!("{RANGE_STUB_MSG}")
    }
}