Struct Chain

Source
pub struct Chain<T> { /* private fields */ }

Implementations§

Source§

impl<T, const N: usize> Chain<[T; N]>

Source

pub fn as_slice(self, cb: impl FnOnce(&[T])) -> Self

See documentation for [T; N]::as_slice for more details on the underlying function.

Source

pub fn each_ref(self, cb: impl FnOnce([&T; N])) -> Self

See documentation for [T; N]::each_ref for more details on the underlying function.

Source

pub fn each_mut(self, cb: impl FnOnce([&mut T; N])) -> Self

See documentation for [T; N]::each_mut for more details on the underlying function.

Source§

impl<'h, T, const N: usize> Chain<&'h mut [T; N]>

Source

pub fn as_slice(self, cb: impl FnOnce(&[T])) -> Self

See documentation for [T; N]::as_slice for more details on the underlying function.

Source

pub fn each_ref(self, cb: impl FnOnce([&T; N])) -> Self

See documentation for [T; N]::each_ref for more details on the underlying function.

Source

pub fn each_mut(self, cb: impl FnOnce([&mut T; N])) -> Self

See documentation for [T; N]::each_mut for more details on the underlying function.

Source§

impl<T, const N: usize> Chain<[T; N]>

Source

pub fn map<T2>(self, f: impl FnMut(T) -> T2) -> Chain<[T2; N]>

See documentation for [T; N]::map for more details on the underlying function.

Source§

impl Chain<String>

Source

pub fn clear(self) -> Self

See documentation for String::clear for more details on the underlying function.

Source

pub fn len(self, out: impl Output<usize>) -> Self

See documentation for String::len for more details on the underlying function.

Source

pub fn push(self, ch: char) -> Self

See documentation for String::push for more details on the underlying function.

Source

pub fn push_str(self, string: &str) -> Self

See documentation for String::push_str for more details on the underlying function.

Source

pub fn reserve(self, additional: usize) -> Self

See documentation for String::reserve for more details on the underlying function.

Source

pub fn reserve_exact(self, additional: usize) -> Self

See documentation for String::reserve_exact for more details on the underlying function.

Source

pub fn retain(self, f: impl FnMut(char) -> bool) -> Self

See documentation for String::retain for more details on the underlying function.

Source§

impl<'h> Chain<&'h mut String>

Source

pub fn clear(self) -> Self

See documentation for String::clear for more details on the underlying function.

Source

pub fn len(self, out: impl Output<usize>) -> Self

See documentation for String::len for more details on the underlying function.

Source

pub fn push(self, ch: char) -> Self

See documentation for String::push for more details on the underlying function.

Source

pub fn push_str(self, string: &str) -> Self

See documentation for String::push_str for more details on the underlying function.

Source

pub fn reserve(self, additional: usize) -> Self

See documentation for String::reserve for more details on the underlying function.

Source

pub fn reserve_exact(self, additional: usize) -> Self

See documentation for String::reserve_exact for more details on the underlying function.

Source

pub fn retain(self, f: impl FnMut(char) -> bool) -> Self

See documentation for String::retain for more details on the underlying function.

Source§

impl<T> Chain<Vec<T>>

Source

pub unsafe fn align_to<U>(self, cb: impl FnOnce((&[T], &[U], &[T]))) -> Self

§Safety

You must uphold safety invariants of [T]::align_to.

See documentation for [T]::align_to for more details on the underlying function.

Source

pub unsafe fn align_to_mut<U>( self, cb: impl FnOnce((&mut [T], &mut [U], &mut [T])), ) -> Self

§Safety

You must uphold safety invariants of [T]::align_to_mut.

See documentation for [T]::align_to_mut for more details on the underlying function.

Source

pub fn append(self, other: &mut impl ChainConversions<Inner = Vec<T>>) -> Self

See documentation for Vec::append for more details on the underlying function.

See documentation for [T]::binary_search for more details on the underlying function.

Source

pub fn binary_search_by( self, f: impl FnMut(&T) -> Ordering, out: impl Output<Result<usize, usize>>, ) -> Self

See documentation for [T]::binary_search_by for more details on the underlying function.

Source

pub fn binary_search_by_key<B>( self, b: &B, f: impl FnMut(&T) -> B, out: impl Output<Result<usize, usize>>, ) -> Self
where B: Ord,

See documentation for [T]::binary_search_by_key for more details on the underlying function.

Source

pub fn capacity(self, out: impl Output<usize>) -> Self

See documentation for Vec::capacity for more details on the underlying function.

Source

pub fn clear(self) -> Self

See documentation for Vec::clear for more details on the underlying function.

Source

pub fn dedup(self) -> Self
where T: PartialEq,

See documentation for Vec::dedup for more details on the underlying function.

Source

pub fn dedup_by(self, same_bucket: impl FnMut(&mut T, &mut T) -> bool) -> Self

See documentation for Vec::dedup_by for more details on the underlying function.

Source

pub fn dedup_by_key<K>(self, key: impl FnMut(&mut T) -> K) -> Self
where K: PartialEq,

See documentation for Vec::dedup_by_key for more details on the underlying function.

Source

pub fn fill(self, value: T) -> Self
where T: Clone,

See documentation for [T]::fill for more details on the underlying function.

Source

pub fn fill_with(self, f: impl FnMut() -> T) -> Self

See documentation for [T]::fill_with for more details on the underlying function.

Source

pub fn insert(self, index: usize, element: T) -> Self

See documentation for Vec::insert for more details on the underlying function.

Source

pub fn is_empty(self, out: impl Output<bool>) -> Self

See documentation for Vec::is_empty for more details on the underlying function.

Source

pub fn len(self, out: impl Output<usize>) -> Self

See documentation for Vec::len for more details on the underlying function.

Source

pub fn pop(self, out: impl Output<Option<T>>) -> Self

See documentation for Vec::pop for more details on the underlying function.

Source

pub fn push(self, value: T) -> Self

See documentation for Vec::push for more details on the underlying function.

Source

pub fn remove(self, index: usize, out: impl Output<T>) -> Self

See documentation for Vec::remove for more details on the underlying function.

Source

pub fn reserve(self, additional: usize) -> Self

See documentation for Vec::reserve for more details on the underlying function.

Source

pub fn reserve_exact(self, additional: usize) -> Self

See documentation for Vec::reserve_exact for more details on the underlying function.

Source

pub fn resize(self, new_len: usize, value: T) -> Self
where T: Clone,

See documentation for Vec::resize for more details on the underlying function.

Source

pub fn resize_with(self, new_len: usize, f: impl FnMut() -> T) -> Self

See documentation for Vec::resize_with for more details on the underlying function.

Source

pub fn retain(self, f: impl FnMut(&T) -> bool) -> Self

See documentation for Vec::retain for more details on the underlying function.

Source

pub fn retain_mut(self, f: impl FnMut(&mut T) -> bool) -> Self

See documentation for Vec::retain_mut for more details on the underlying function.

Source

pub unsafe fn set_len(self, new_len: usize) -> Self

§Safety

You must uphold safety invariants of Vec::set_len.

See documentation for Vec::set_len for more details on the underlying function.

Source

pub fn shrink_to(self, min_capacity: usize) -> Self

See documentation for Vec::shrink_to for more details on the underlying function.

Source

pub fn shrink_to_fit(self) -> Self

See documentation for Vec::shrink_to_fit for more details on the underlying function.

Source

pub fn sort(self) -> Self
where T: Ord,

See documentation for [T]::sort for more details on the underlying function.

Source

pub fn sort_by(self, compare: impl FnMut(&T, &T) -> Ordering) -> Self

See documentation for [T]::sort_by for more details on the underlying function.

Source

pub fn sort_by_key<K>(self, f: impl FnMut(&T) -> K) -> Self
where K: Ord,

See documentation for [T]::sort_by_key for more details on the underlying function.

Source

pub fn sort_by_cached_key<K>(self, f: impl FnMut(&T) -> K) -> Self
where K: Ord,

See documentation for [T]::sort_by_cached_key for more details on the underlying function.

Source

pub fn spare_capacity_mut(self, cb: impl FnOnce(&mut [MaybeUninit<T>])) -> Self

See documentation for Vec::spare_capacity_mut for more details on the underlying function.

Source§

impl<'h, T> Chain<&'h mut Vec<T>>

Source

pub unsafe fn align_to<U>(self, cb: impl FnOnce((&[T], &[U], &[T]))) -> Self

§Safety

You must uphold safety invariants of [T]::align_to.

See documentation for [T]::align_to for more details on the underlying function.

Source

pub unsafe fn align_to_mut<U>( self, cb: impl FnOnce((&mut [T], &mut [U], &mut [T])), ) -> Self

§Safety

You must uphold safety invariants of [T]::align_to_mut.

See documentation for [T]::align_to_mut for more details on the underlying function.

Source

pub fn append(self, other: &mut impl ChainConversions<Inner = Vec<T>>) -> Self

See documentation for Vec::append for more details on the underlying function.

Source

pub fn binary_search( self, x: &T, out: impl Output<Result<usize, usize>>, ) -> Self
where T: Ord,

See documentation for [T]::binary_search for more details on the underlying function.

Source

pub fn binary_search_by( self, f: impl FnMut(&T) -> Ordering, out: impl Output<Result<usize, usize>>, ) -> Self

See documentation for [T]::binary_search_by for more details on the underlying function.

Source

pub fn binary_search_by_key<B>( self, b: &B, f: impl FnMut(&T) -> B, out: impl Output<Result<usize, usize>>, ) -> Self
where B: Ord,

See documentation for [T]::binary_search_by_key for more details on the underlying function.

Source

pub fn capacity(self, out: impl Output<usize>) -> Self

See documentation for Vec::capacity for more details on the underlying function.

Source

pub fn clear(self) -> Self

See documentation for Vec::clear for more details on the underlying function.

Source

pub fn dedup(self) -> Self
where T: PartialEq,

See documentation for Vec::dedup for more details on the underlying function.

Source

pub fn dedup_by(self, same_bucket: impl FnMut(&mut T, &mut T) -> bool) -> Self

See documentation for Vec::dedup_by for more details on the underlying function.

Source

pub fn dedup_by_key<K>(self, key: impl FnMut(&mut T) -> K) -> Self
where K: PartialEq,

See documentation for Vec::dedup_by_key for more details on the underlying function.

Source

pub fn fill(self, value: T) -> Self
where T: Clone,

See documentation for [T]::fill for more details on the underlying function.

Source

pub fn fill_with(self, f: impl FnMut() -> T) -> Self

See documentation for [T]::fill_with for more details on the underlying function.

Source

pub fn insert(self, index: usize, element: T) -> Self

See documentation for Vec::insert for more details on the underlying function.

Source

pub fn is_empty(self, out: impl Output<bool>) -> Self

See documentation for Vec::is_empty for more details on the underlying function.

Source

pub fn len(self, out: impl Output<usize>) -> Self

See documentation for Vec::len for more details on the underlying function.

Source

pub fn pop(self, out: impl Output<Option<T>>) -> Self

See documentation for Vec::pop for more details on the underlying function.

Source

pub fn push(self, value: T) -> Self

See documentation for Vec::push for more details on the underlying function.

Source

pub fn remove(self, index: usize, out: impl Output<T>) -> Self

See documentation for Vec::remove for more details on the underlying function.

Source

pub fn reserve(self, additional: usize) -> Self

See documentation for Vec::reserve for more details on the underlying function.

Source

pub fn reserve_exact(self, additional: usize) -> Self

See documentation for Vec::reserve_exact for more details on the underlying function.

Source

pub fn resize(self, new_len: usize, value: T) -> Self
where T: Clone,

See documentation for Vec::resize for more details on the underlying function.

Source

pub fn resize_with(self, new_len: usize, f: impl FnMut() -> T) -> Self

See documentation for Vec::resize_with for more details on the underlying function.

Source

pub fn retain(self, f: impl FnMut(&T) -> bool) -> Self

See documentation for Vec::retain for more details on the underlying function.

Source

pub fn retain_mut(self, f: impl FnMut(&mut T) -> bool) -> Self

See documentation for Vec::retain_mut for more details on the underlying function.

Source

pub unsafe fn set_len(self, new_len: usize) -> Self

§Safety

You must uphold safety invariants of Vec::set_len.

See documentation for Vec::set_len for more details on the underlying function.

Source

pub fn shrink_to(self, min_capacity: usize) -> Self

See documentation for Vec::shrink_to for more details on the underlying function.

Source

pub fn shrink_to_fit(self) -> Self

See documentation for Vec::shrink_to_fit for more details on the underlying function.

Source

pub fn sort(self) -> Self
where T: Ord,

See documentation for [T]::sort for more details on the underlying function.

Source

pub fn sort_by(self, compare: impl FnMut(&T, &T) -> Ordering) -> Self

See documentation for [T]::sort_by for more details on the underlying function.

Source

pub fn sort_by_key<K>(self, f: impl FnMut(&T) -> K) -> Self
where K: Ord,

See documentation for [T]::sort_by_key for more details on the underlying function.

Source

pub fn sort_by_cached_key<K>(self, f: impl FnMut(&T) -> K) -> Self
where K: Ord,

See documentation for [T]::sort_by_cached_key for more details on the underlying function.

Source

pub fn spare_capacity_mut(self, cb: impl FnOnce(&mut [MaybeUninit<T>])) -> Self

See documentation for Vec::spare_capacity_mut for more details on the underlying function.

Source§

impl<T> Chain<T>

Source

pub fn from_inner(inner: T) -> Self

Source

pub fn into_inner(self) -> T

Source

pub fn as_inner(&self) -> &T

Source

pub fn as_inner_mut(&mut self) -> &mut T

Source

pub fn with_inner(self, f: impl FnOnce(&mut T)) -> Self

Takes a closure that is called, passing in a reference to the inner value

This is useful for if there is something we have not implemented, or you otherwise need to borrow the inner struct for something, but are in the middle of some chain. It lets you do otherwise nonchainable operations inline with other chaining operations, so no need to break the chain c:

§Examples
let chain = VecChain::<usize>::new();

// let's pretend `push` and `reserve` don't already have chainable versions...
let chain = chain
   .with_inner(|v| v.reserve(10))
   .with_inner(|v| v.push(1))
   .with_inner(|v| v.push(2));

assert!(chain.as_inner().len() == 2);
assert!(chain.as_inner().capacity() >= 10);

Trait Implementations§

Source§

impl<T, T2> AsMut<T2> for Chain<T>
where T: AsMut<T2>,

Source§

fn as_mut(&mut self) -> &mut T2

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T, T2> AsRef<T2> for Chain<T>
where T: AsRef<T2>,

Source§

fn as_ref(&self) -> &T2

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'h, T, const N: usize> ChainConversions for Chain<&'h mut [T; N]>

Source§

type Inner = [T; N]

Source§

type MutChain<'mut_chain> = Chain<&'mut_chain mut [T; N]> where Self: 'mut_chain

Source§

fn as_inner(&self) -> &Self::Inner

Source§

fn as_inner_mut(&mut self) -> &mut Self::Inner

Source§

fn as_mut_chain(&mut self) -> Chain<&mut [T; N]>

Source§

impl<'h> ChainConversions for Chain<&'h mut String>

Source§

type Inner = String

Source§

type MutChain<'mut_chain> = Chain<&'mut_chain mut String> where Self: 'mut_chain

Source§

fn as_inner(&self) -> &Self::Inner

Source§

fn as_inner_mut(&mut self) -> &mut Self::Inner

Source§

fn as_mut_chain(&mut self) -> Chain<&mut String>

Source§

impl<'h, T> ChainConversions for Chain<&'h mut Vec<T>>

Source§

type Inner = Vec<T>

Source§

type MutChain<'mut_chain> = Chain<&'mut_chain mut Vec<T>> where Self: 'mut_chain

Source§

fn as_inner(&self) -> &Self::Inner

Source§

fn as_inner_mut(&mut self) -> &mut Self::Inner

Source§

fn as_mut_chain(&mut self) -> Chain<&mut Vec<T>>

Source§

impl<T, const N: usize> ChainConversions for Chain<[T; N]>

Source§

type Inner = [T; N]

Source§

type MutChain<'mut_chain> = Chain<&'mut_chain mut [T; N]> where Self: 'mut_chain

Source§

fn as_inner(&self) -> &Self::Inner

Source§

fn as_inner_mut(&mut self) -> &mut Self::Inner

Source§

fn as_mut_chain(&mut self) -> Chain<&mut [T; N]>

Source§

impl ChainConversions for Chain<String>

Source§

type Inner = String

Source§

type MutChain<'mut_chain> = Chain<&'mut_chain mut String> where Self: 'mut_chain

Source§

fn as_inner(&self) -> &Self::Inner

Source§

fn as_inner_mut(&mut self) -> &mut Self::Inner

Source§

fn as_mut_chain(&mut self) -> Chain<&mut String>

Source§

impl<T> ChainConversions for Chain<Vec<T>>

Source§

type Inner = Vec<T>

Source§

type MutChain<'mut_chain> = Chain<&'mut_chain mut Vec<T>> where Self: 'mut_chain

Source§

fn as_inner(&self) -> &Self::Inner

Source§

fn as_inner_mut(&mut self) -> &mut Self::Inner

Source§

fn as_mut_chain(&mut self) -> Chain<&mut Vec<T>>

Source§

impl<T> Clone for Chain<T>
where T: Clone,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Chain<T>
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Chain<T>
where T: Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> Display for Chain<T>
where T: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, T2> PartialEq<T2> for Chain<T>
where T: PartialEq<T2>,

Source§

fn eq(&self, other: &T2) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &T2) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Copy for Chain<T>
where T: Copy,

Auto Trait Implementations§

§

impl<T> Freeze for Chain<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Chain<T>
where T: RefUnwindSafe,

§

impl<T> Send for Chain<T>
where T: Send,

§

impl<T> Sync for Chain<T>
where T: Sync,

§

impl<T> Unpin for Chain<T>
where T: Unpin,

§

impl<T> UnwindSafe for Chain<T>
where T: UnwindSafe,

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> ChainInner for T

Source§

fn from_chain(chain: Chain<Self>) -> Self

Source§

fn into_chain(self) -> Chain<Self>

Source§

fn chain_mut(&mut self) -> Chain<&mut Self>

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> WithSelf for T

Source§

fn with_self(self, f: impl FnOnce(&mut Self)) -> Self

Takes ownership of the value, passing a mutable reference of it to a closure, then returning ownership of the value again