Struct Sorted

Source
pub struct Sorted<'a, T: 'a, O: 'a> { /* private fields */ }
Expand description

Guarantees that the inner container is sorted in a specific order.

The Sortable trait is a requirement for all containers T being wrapped with Sorted<T> to enforce certain guarantees for operations that arent strictly read only (i.e creating iterators). See the documentation of Sortable for details. Sortable: trait.Sortable.html

Implementations§

Source§

impl<'a, T, O> Sorted<'a, T, O>

Source

pub fn as_inner(&self) -> &T

Source

pub fn deref_inner<U>(&'a self) -> Sorted<'a, &U, O>
where U: ?Sized, T: Deref<Target = U>,

Source

pub fn iter(&'a self) -> SortedIter<<&T as IntoIterator>::IntoIter, O>

Source

pub fn from_iter<I>(iter: I) -> Sorted<'a, T, O>
where T: RetainsOrder + FromIterator<<T as Collection>::Item>, I: IntoIterator<Item = T::Item>, I::IntoIter: SortedIterator<Ordering = O>, <I as IntoIterator>::IntoIter: SortedIterator<Ordering = O>,

Builds a sorted collection of type T from a sorted iterator.

As the RetainsOrder trait is required to be implemented for T, it’s guaranteed that the order of the input iterator is preserved. Since the iterator must implement SortedIterator, you’ll safely get a sorted collection. Sortable: trait.Sortable.html

Source§

impl<'a, T, O> Sorted<'a, T, O>
where T: Sortable, O: SortOrder<T::Item>,

Source

pub fn by_sorting(collection: T) -> Self

Source§

impl<'a, T, O> Sorted<'a, T, O>
where T: SearchableByOrder<O>, O: SortOrder<T::Item>,

Source

pub fn search(&self, a: &T::Item) -> Result<usize, usize>

Source§

impl<'a, T, O> Sorted<'a, T, O>
where T: Sortable + SortedInsert<O>, O: SortOrder<T::Item>,

Source

pub fn insert(&mut self, x: T::Item)

Source§

impl<'a, T, O> Sorted<'a, T, O>

Source

pub fn as_ref<U>(&self) -> Sorted<'a, &U, O>
where T: AsRef<U>, U: ?Sized + RetainsOrder,

Similar to Option::as_ref. It’s mapping the inner type with AsRef.

Trait Implementations§

Source§

impl<'a, T, O> Deref for Sorted<'a, T, O>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, T, O> IntoIterator for Sorted<'a, T, O>
where T: IntoIterator<Item = <T as Collection>::Item> + Sortable,

Source§

type Item = <T as Collection>::Item

The type of the elements being iterated over.
Source§

type IntoIter = SortedIter<<T as IntoIterator>::IntoIter, O>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a, T, O> Freeze for Sorted<'a, T, O>
where T: Freeze,

§

impl<'a, T, O> RefUnwindSafe for Sorted<'a, T, O>

§

impl<'a, T, O> Send for Sorted<'a, T, O>
where T: Send, O: Sync,

§

impl<'a, T, O> Sync for Sorted<'a, T, O>
where T: Sync, O: Sync,

§

impl<'a, T, O> Unpin for Sorted<'a, T, O>
where T: Unpin,

§

impl<'a, T, O> UnwindSafe for Sorted<'a, T, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.