Skip to main content

ListIndex

Trait ListIndex 

Source
pub trait ListIndex<Idx: ?Sized> {
    type Output;

    // Required method
    fn index(&self, index: Idx) -> &Self::Output;
}
Expand description

Indexing for lists using typenum-based indices and ranges.

The index type establishes that the selected field or range exists.

§Examples

use cel_runtime::{IntoTupleList, ListIndex};
let list = ("first", 7u8).into_tuple_list();
assert_eq!(*list.index(typenum::U1::new()), 7);

Required Associated Types§

Source

type Output

The output reference type when indexing with Idx.

Required Methods§

Source

fn index(&self, index: Idx) -> &Self::Output

Borrows the element or sublist selected by index.

  • Complexity: Representation-dependent; recursive suffix traversal takes O(i) steps for source index i.
§Examples

See ListIndex.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ListIndex<RangeFrom<UTerm>> for ()

Source§

fn index(&self, _index: RangeFrom<U0>) -> &Self::Output

Borrows the empty suffix at the only valid empty-list boundary.

Source§

type Output = ()

Source§

impl<H: 'static, T, U: Unsigned, B: Bit> ListIndex<RangeFrom<UInt<U, B>>> for (H, T)
where T: ListIndex<RangeFrom<Sub1<UInt<U, B>>>> + List, UInt<U, B>: Sub<B1>,

Source§

fn index(&self, index: RangeFrom<UInt<U, B>>) -> &Self::Output

Borrows the suffix at the type-checked source index.

  • Complexity: O(i) tail traversals for source index i.
Source§

type Output = <T as ListIndex<RangeFrom<<UInt<U, B> as Sub<B1>>::Output>>>::Output

Source§

impl<H: 'static, T, U: Unsigned, B: Bit> ListIndex<UInt<U, B>> for (H, T)
where T: ListIndex<Sub1<UInt<U, B>>> + List, UInt<U, B>: Sub<B1>,

Source§

fn index(&self, index: UInt<U, B>) -> &Self::Output

Borrows the field at the type-checked source index.

  • Complexity: O(i) tail traversals for source index i.
Source§

type Output = <T as ListIndex<<UInt<U, B> as Sub<B1>>::Output>>::Output

Source§

impl<H: 'static, T: List> ListIndex<RangeFrom<UTerm>> for (H, T)

Source§

fn index(&self, _index: RangeFrom<U0>) -> &Self::Output

Borrows the complete suffix starting at zero.

Source§

type Output = (H, T)

Source§

impl<H: 'static, T: List> ListIndex<UTerm> for (H, T)

Source§

fn index(&self, _index: U0) -> &Self::Output

Borrows the first source field.

Source§

type Output = H

Implementors§

Source§

impl<H: 'static, T, U: Unsigned, B: Bit> ListIndex<RangeFrom<UInt<U, B>>> for CStackList<H, T>
where T: ListIndex<RangeFrom<Sub1<UInt<U, B>>>> + List + CStackListHeadLimit, UInt<U, B>: Sub<B1>,

Source§

type Output = <T as ListIndex<RangeFrom<<UInt<U, B> as Sub<B1>>::Output>>>::Output

Source§

impl<H: 'static, T, U: Unsigned, B: Bit> ListIndex<RangeTo<UInt<U, B>>> for CStackList<H, T>
where T: ListIndex<RangeTo<Sub1<UInt<U, B>>>> + List + CStackListHeadLimit, <T as ListIndex<RangeTo<Sub1<UInt<U, B>>>>>::Output: List, UInt<U, B>: Sub<B1>,

Source§

type Output = <<T as ListIndex<RangeTo<<UInt<U, B> as Sub<B1>>::Output>>>::Output as List>::Push<H>

Source§

impl<H: 'static, T, U: Unsigned, B: Bit> ListIndex<RangeToInclusive<UInt<U, B>>> for CStackList<H, T>

Source§

type Output = <<T as ListIndex<RangeToInclusive<<UInt<U, B> as Sub<B1>>::Output>>>::Output as List>::Push<H>

Source§

impl<H: 'static, T, U: Unsigned, B: Bit> ListIndex<UInt<U, B>> for CStackList<H, T>
where T: ListIndex<Sub1<UInt<U, B>>> + List + CStackListHeadLimit, UInt<U, B>: Sub<B1>,

Source§

type Output = <T as ListIndex<<UInt<U, B> as Sub<B1>>::Output>>::Output

Source§

impl<H: 'static, T: List + CStackListHeadLimit> ListIndex<RangeFrom<UTerm>> for CStackList<H, T>

Source§

impl<H: 'static, T: List + CStackListHeadLimit> ListIndex<RangeTo<UTerm>> for CStackList<H, T>

Source§

impl<H: 'static, T: List + CStackListHeadLimit> ListIndex<RangeToInclusive<UTerm>> for CStackList<H, T>

Source§

impl<H: 'static, T: List + CStackListHeadLimit> ListIndex<UTerm> for CStackList<H, T>