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,
{ ... }
}
Expand description
A type behaving like a sequence over the type Item
.
Associated Types
type Iterator: DoubleEndedIterator<Item = &'a Item>
type Iterator: DoubleEndedIterator<Item = &'a Item>
The iterator type of the sequence.
Required methods
Provided methods
Returns a prefix with length len
of this sequence.
Panics if len >= self.len()
.
Returns a suffix with length len
of this sequence.
Panics if len >= self.len()
.
fn is_proper_subsequence_of(&'a self, other: &Self) -> bool where
Item: Eq,
fn is_proper_subsequence_of(&'a self, other: &Self) -> bool where
Item: Eq,
Returns true if this is a proper subsequence of the given sequence. Proper means that the sequences are not equal.
Returns true if this sequence contains the given item.
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.
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,
fn to_debug_string(&'a self) -> String where
Item: Debug,
Converts the sequence to a string using the debug formatting of the items.
use traitsequence::interface::Sequence;
let sequence = [0, 2, 1];
debug_assert_eq!(sequence.to_debug_string(), "[0, 2, 1]".to_string());
let sequence = ["a", "c", "b"];
debug_assert_eq!(sequence.to_debug_string(), "[\"a\", \"c\", \"b\"]".to_string());