pub trait Sequence<Item, Subsequence: Sequence<Item, Subsequence> + ?Sized>: Index<usize, Output = Item> + Index<Range<usize>, Output = Subsequence> {
    type Iterator<'a>: DoubleEndedIterator<Item = &'a Item>
       where Self: 'a,
             Item: 'a;

    // Required methods
    fn iter(&self) -> Self::Iterator<'_>;
    fn len(&self) -> usize;

    // Provided methods
    fn prefix(&self, len: usize) -> &Subsequence { ... }
    fn suffix(&self, len: usize) -> &Subsequence { ... }
    fn is_empty(&self) -> bool { ... }
    fn first(&self) -> Option<&Item> { ... }
    fn last(&self) -> Option<&Item> { ... }
    fn is_proper_subsequence_of(&self, other: &Self) -> bool
       where Item: Eq { ... }
    fn contains(&self, item: &Item) -> bool
       where Item: Eq { ... }
    fn forward_merge_iter_assume_mergeable<'a>(
        &'a self,
        suffix: &'a Self
    ) -> Chain<Self::Iterator<'a>, Skip<Self::Iterator<'a>>>
       where Item: Eq { ... }
    fn backward_merge_iter_assume_mergeable<'a>(
        &'a self,
        suffix: &'a Self
    ) -> Chain<Self::Iterator<'a>, Skip<Self::Iterator<'a>>>
       where Item: Eq { ... }
    fn to_debug_string(&self) -> String
       where Item: Debug { ... }
}
Expand description

A type behaving like a sequence over the type Item.

Required Associated Types§

source

type Iterator<'a>: DoubleEndedIterator<Item = &'a Item> where Self: 'a, Item: 'a

The iterator type of the sequence.

Required Methods§

source

fn iter(&self) -> Self::Iterator<'_>

Returns an iterator over the sequence.

source

fn len(&self) -> usize

Returns the length of the sequence.

Provided Methods§

source

fn prefix(&self, len: usize) -> &Subsequence

Returns a prefix with length len of this sequence. Panics if len >= self.len().

source

fn suffix(&self, len: usize) -> &Subsequence

Returns a suffix with length len of this sequence. Panics if len >= self.len().

source

fn is_empty(&self) -> bool

Returns true if the sequence is empty.

source

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

Returns the first item of the sequence.

source

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

Returns the last item of the sequence.

source

fn is_proper_subsequence_of(&self, other: &Self) -> boolwhere Item: Eq,

Returns true if this is a proper subsequence of the given sequence. Proper means that the sequences are not equal.

source

fn contains(&self, item: &Item) -> boolwhere Item: Eq,

Returns true if this sequence contains the given item.

source

fn forward_merge_iter_assume_mergeable<'a>( &'a self, suffix: &'a Self ) -> Chain<Self::Iterator<'a>, Skip<Self::Iterator<'a>>>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.

source

fn backward_merge_iter_assume_mergeable<'a>( &'a self, suffix: &'a Self ) -> Chain<Self::Iterator<'a>, Skip<Self::Iterator<'a>>>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.

source

fn to_debug_string(&self) -> Stringwhere 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());

Implementations on Foreign Types§

source§

impl<Item> Sequence<Item, [Item]> for Vec<Item>

§

type Iterator<'a> = Iter<'a, Item> where Item: 'a

source§

fn iter(&self) -> Self::Iterator<'_>

source§

fn len(&self) -> usize

source§

impl<Item> Sequence<Item, [Item]> for [Item]

§

type Iterator<'a> = Iter<'a, Item> where Item: 'a

source§

fn iter(&self) -> Self::Iterator<'_>

source§

fn len(&self) -> usize

Implementors§