[−][src]Trait generic_std::Sequence
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.
Required methods
fn len(&self) -> usize
fn contains<'a>(&'a self, x: &T) -> bool where
T: PartialEq,
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,
<Self::H1Iterator as PlugLifetime<'a>>::T: StreamingIterator,
Provided methods
Loading content...Implementations on Foreign Types
impl<T> Sequence<T> for Vec<T> where
T: 'static,
[src]
T: 'static,
type H1Iterator = TypedH1Iter<T>
fn len(&self) -> usize
[src]
fn is_empty(&self) -> bool
[src]
fn contains<'a>(&'a self, x: &T) -> bool where
T: PartialEq,
[src]
T: PartialEq,
fn get(&self, index: usize) -> Option<&T>
[src]
fn first(&self) -> Option<&T>
[src]
fn last(&self) -> Option<&T>
[src]
fn iter<'a>(&'a self) -> <Self::H1Iterator as PlugLifetime<'a>>::T where
<Self::H1Iterator as PlugLifetime<'a>>::T: StreamingIterator,
[src]
<Self::H1Iterator as PlugLifetime<'a>>::T: StreamingIterator,