[][src]Trait generic_std::Sequence

pub trait Sequence<T> {
    type H1Iterator: for<'a> PlugLifetime<'a>;
    fn len(&self) -> usize;
fn contains<'a>(&'a self, x: &T) -> bool
    where
        T: PartialEq
;
fn get(&self, index: usize) -> Option<&T>;
fn iter<'a>(&'a self) -> <Self::H1Iterator as PlugLifetime<'a>>::T
    where
        <Self::H1Iterator as PlugLifetime<'a>>::T: StreamingIterator
; fn is_empty(&self) -> bool { ... }
fn first(&self) -> Option<&T> { ... }
fn last(&self) -> Option<&T> { ... } }

Trait for collections that store elements in a linear sequence, allowing for linear traversal and indexing with an usize.

Note

The H1Iterator bounds are not specific enough due to language limitations. The correct declaration for the trait and H1Iterator is:

This example deliberately fails to compile
trait Sequence<'a, T>
where
  T: 'a
{
  type H1Iterator: for<'b> PlugLifetime<'b>
  where
    'a: 'b,
    <H1Iterator as PlugLifetime<'b>>::T: StreamingIterator;
  ...
}

Because we can't declare 'a: 'b, implementors must only allow T: 'static. In other words, we can't declare that all items outlive the iterator for any specific lifetime (so that stuff like next() returning a &T is valid if T contains references), so we must use a shotgun and prohibit T from containing any non-'static references.

Also, where clauses in associated types are not stable so we have to move StreamingIterator bound to the iter() declaration.

Associated Types

type H1Iterator: for<'a> PlugLifetime<'a>

HKT iterator with a lifetime slot.

Loading content...

Required methods

fn len(&self) -> usize

fn contains<'a>(&'a self, x: &T) -> bool where
    T: PartialEq

fn get(&self, index: usize) -> Option<&T>

fn iter<'a>(&'a self) -> <Self::H1Iterator as PlugLifetime<'a>>::T where
    <Self::H1Iterator as PlugLifetime<'a>>::T: StreamingIterator

Loading content...

Provided methods

fn is_empty(&self) -> bool

fn first(&self) -> Option<&T>

fn last(&self) -> Option<&T>

Loading content...

Implementations on Foreign Types

impl<T> Sequence<T> for Vec<T> where
    T: 'static, 
[src]

type H1Iterator = TypedH1Iter<T>

Loading content...

Implementors

Loading content...