Trait traitsequence::interface::Sequence [−][src]
pub trait Sequence<'a, Item: 'a, Subsequence: Sequence<'a, Item, Subsequence> + ?Sized>: Index<usize, Output = Item> + Index<Range<usize>, Output = Subsequence> { type Iterator: DoubleEndedIterator<Item = &'a Item>; fn iter(&'a self) -> Self::Iterator; fn len(&self) -> usize; fn prefix(&'a self, len: usize) -> &Subsequence { ... } fn suffix(&'a self, len: usize) -> &Subsequence { ... } fn is_empty(&self) -> bool { ... } fn first(&'a self) -> Option<&Item> { ... } fn last(&'a self) -> Option<&Item> { ... } fn is_proper_subsequence_of(&'a self, other: &Self) -> bool
where
Item: Eq, { ... } fn contains(&'a self, item: &Item) -> bool
where
Item: Eq, { ... } fn forward_merge_iter_assume_mergeable(
&'a self,
suffix: &'a Self
) -> Chain<Self::Iterator, Skip<Self::Iterator>>
where
Item: Eq, { ... } fn backward_merge_iter_assume_mergeable(
&'a self,
suffix: &'a Self
) -> Chain<Self::Iterator, Skip<Self::Iterator>>
where
Item: Eq, { ... } fn to_debug_string(&'a self) -> String
where
Item: Debug, { ... } }
A type behaving like a sequence over the type Item.
Associated Types
type Iterator: DoubleEndedIterator<Item = &'a Item>[src]
The iterator type of the sequence.
Required methods
fn iter(&'a self) -> Self::Iterator[src]
Returns an iterator over the sequence.
fn len(&self) -> usize[src]
Returns the length of the sequence.
Provided methods
fn prefix(&'a self, len: usize) -> &Subsequence[src]
Returns a prefix with length len of this sequence.
Panics if len >= self.len().
fn suffix(&'a self, len: usize) -> &Subsequence[src]
Returns a suffix with length len of this sequence.
Panics if len >= self.len().
fn is_empty(&self) -> bool[src]
Returns true if the sequence is empty.
fn first(&'a self) -> Option<&Item>[src]
Returns the first item of the sequence.
fn last(&'a self) -> Option<&Item>[src]
Returns the last item of the sequence.
fn is_proper_subsequence_of(&'a self, other: &Self) -> bool where
Item: Eq, [src]
Item: Eq,
Returns true if this is a proper subsequence of the given sequence. Proper means that the sequences are not equal.
fn contains(&'a self, item: &Item) -> bool where
Item: Eq, [src]
Item: Eq,
Returns true if this sequence contains the given item.
fn forward_merge_iter_assume_mergeable(
&'a self,
suffix: &'a Self
) -> Chain<Self::Iterator, Skip<Self::Iterator>> where
Item: Eq, [src]
&'a self,
suffix: &'a Self
) -> Chain<Self::Iterator, Skip<Self::Iterator>> where
Item: Eq,
Returns an iterator over this sequence merged before the given other sequence under the assumption that the sequences can be merged this way. A merge is possible if a non-empty suffix of this sequence equals a non-empty prefix of the other sequence.
The method panics if this sequence does not contain the first item of the other sequence or the other sequence is empty. The method does not fail if the sequences are not mergeable for other reasons.
fn backward_merge_iter_assume_mergeable(
&'a self,
suffix: &'a Self
) -> Chain<Self::Iterator, Skip<Self::Iterator>> where
Item: Eq, [src]
&'a self,
suffix: &'a Self
) -> Chain<Self::Iterator, Skip<Self::Iterator>> where
Item: Eq,
Returns an iterator over this sequence merged after the given other sequence under the assumption that the sequences can be merged this way. A merge is possible if a non-empty prefix of this sequence equals a non-empty suffix of the other sequence.
The method panics if the other sequence does not contain the first item of this sequence or this sequence is empty. The method does not fail if the sequences are not mergeable for other reasons.
fn to_debug_string(&'a self) -> String where
Item: Debug, [src]
Item: Debug,
Converts the sequence to a string using the debug formatting of the items.
use traitsequence::interface::Sequence; let sequence = [0, 2, 1]; assert_eq!(sequence.to_debug_string(), "[0, 2, 1]".to_string()); let sequence = ["a", "c", "b"]; assert_eq!(sequence.to_debug_string(), "[\"a\", \"c\", \"b\"]".to_string());