MutFoldChainSlice

Trait MutFoldChainSlice 

Source
pub trait MutFoldChainSlice<'a, T: 'a, D: Clone + 'a>: FoldChainSlice<'a, T, D> + Sealed {
Show 30 methods // Required methods fn as_mut( self, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, Self::Simplification>; fn borrow_mut<'b>( &'b mut self, ) -> MutFoldChainSliceStruct<'b, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, Self::Simplification>; // Provided methods fn mut_view_drop_left_until( self, predicate: impl Fn(&D) -> bool, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, <Self::IsFlushLeft as Bool>::And<Self::IsReversed>, <Self::IsFlushRight as Bool>::And<<Self::IsReversed as Bool>::Not>, T, Self::OriginalD, Self::Settings, Self::Simplification> { ... } fn mut_view_take_right_until( self, predicate: impl Fn(&D) -> bool, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, <Self::IsFlushLeft as Bool>::And<Self::IsReversed>, <Self::IsFlushRight as Bool>::And<<Self::IsReversed as Bool>::Not>, T, Self::OriginalD, Self::Settings, Self::Simplification> { ... } fn mut_view_drop_right_until( self, predicate: impl Fn(&D) -> bool, ) -> MutFoldChainSliceStruct<'a, <<Self::IsReversed as Bool>::Not as Bool>::Not, <Self::IsFlushLeft as Bool>::And<<Self::IsReversed as Bool>::Not>, <Self::IsFlushRight as Bool>::And<<<Self::IsReversed as Bool>::Not as Bool>::Not>, T, Self::OriginalD, Self::Settings, Self::Simplification> { ... } fn mut_view_take_left_until( self, predicate: impl Fn(&D) -> bool, ) -> MutFoldChainSliceStruct<'a, <<Self::IsReversed as Bool>::Not as Bool>::Not, <Self::IsFlushLeft as Bool>::And<<Self::IsReversed as Bool>::Not>, <Self::IsFlushRight as Bool>::And<<<Self::IsReversed as Bool>::Not as Bool>::Not>, T, Self::OriginalD, Self::Settings, Self::Simplification> { ... } fn mut_view_drop<Predicate: Fn(&D) -> bool, Range: SingleEndedRange<Predicate>>( self, range: Range, ) -> <<Range as SingleEndedRange<Predicate>>::EndIsLeft as Bool>::IfElse<MutFoldChainSliceStruct<'a, <<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not as Bool>::Not, <<Self as FoldChainSlice<'a, T, D>>::IsFlushLeft as Bool>::And<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not>, <<Self as FoldChainSlice<'a, T, D>>::IsFlushRight as Bool>::And<<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not as Bool>::Not>, T, <Self as FoldChainSlice<'a, T, D>>::OriginalD, <Self as FoldChainSlice<'a, T, D>>::Settings, <Self as FoldChainSlice<'a, T, D>>::Simplification>, MutFoldChainSliceStruct<'a, <Self as FoldChainSlice<'a, T, D>>::IsReversed, <<Self as FoldChainSlice<'a, T, D>>::IsFlushLeft as Bool>::And<<Self as FoldChainSlice<'a, T, D>>::IsReversed>, <<Self as FoldChainSlice<'a, T, D>>::IsFlushRight as Bool>::And<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not>, T, <Self as FoldChainSlice<'a, T, D>>::OriginalD, <Self as FoldChainSlice<'a, T, D>>::Settings, <Self as FoldChainSlice<'a, T, D>>::Simplification>> { ... } fn mut_view_take<Predicate: Fn(&D) -> bool, Range: SingleEndedRange<Predicate>>( self, range: Range, ) -> <<Range as SingleEndedRange<Predicate>>::EndIsLeft as Bool>::IfElse<MutFoldChainSliceStruct<'a, <Self as FoldChainSlice<'a, T, D>>::IsReversed, <<Self as FoldChainSlice<'a, T, D>>::IsFlushLeft as Bool>::And<<Self as FoldChainSlice<'a, T, D>>::IsReversed>, <<Self as FoldChainSlice<'a, T, D>>::IsFlushRight as Bool>::And<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not>, T, <Self as FoldChainSlice<'a, T, D>>::OriginalD, <Self as FoldChainSlice<'a, T, D>>::Settings, <Self as FoldChainSlice<'a, T, D>>::Simplification>, MutFoldChainSliceStruct<'a, <<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not as Bool>::Not, <<Self as FoldChainSlice<'a, T, D>>::IsFlushLeft as Bool>::And<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not>, <<Self as FoldChainSlice<'a, T, D>>::IsFlushRight as Bool>::And<<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not as Bool>::Not>, T, <Self as FoldChainSlice<'a, T, D>>::OriginalD, <Self as FoldChainSlice<'a, T, D>>::Settings, <Self as FoldChainSlice<'a, T, D>>::Simplification>> { ... } fn mut_view_reversed( self, ) -> MutFoldChainSliceStruct<'a, <Self::IsReversed as Bool>::Not, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, Self::Simplification> { ... } fn mut_view_with_simplification<NewSimplification: FoldSimplification<T, D>>( self, new_simplification: NewSimplification, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, NewSimplification::ComposeAfterOther<Self::OriginalD, Self::Simplification>> { ... } fn mut_view_simplify<D2: Clone + 'a, Simplifier: for<'x> Fun<&'x D, D2> + Copy + 'a, OP2: Fun<(D2, D2), D2> + Copy + 'a>( self, simplifier: Simplifier, simplified_op: OP2, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, <Self::Simplification as FoldSimplification<T, Self::OriginalD>>::Compose<D2, Simplifier, OP2>> { ... } fn mut_view_simplify_with_shortcut<D2: Clone + 'a, Simplifier: for<'x> Fun<&'x D, D2> + Copy + 'a, OP2: Fun<(D2, D2), D2> + Copy + 'a, EmptyShortcut: Fun<(), D2> + Copy + 'a, DeltaShortcut: for<'x> Fun<&'x T, D2> + Copy + 'a>( self, simplifier: Simplifier, simplified_op: OP2, empty_shortcut: EmptyShortcut, delta_shortcut: DeltaShortcut, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, <Self::Simplification as FoldSimplification<T, Self::OriginalD>>::ComposeWithShortcut<D2, Simplifier, OP2, EmptyShortcut, DeltaShortcut>> { ... } fn mut_view_unsimplify( self, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, ()> { ... } fn pop_left(&mut self) -> Option<T> { ... } fn pop_right(&mut self) -> Option<T> { ... } fn append_left(&mut self, value: T) { ... } fn append_right(&mut self, value: T) { ... } fn set_left_or_err(&mut self, value: T) -> Result<T, T> { ... } fn set_right_or_err(&mut self, value: T) -> Result<T, T> { ... } fn set_left(&mut self, value: T) -> T { ... } fn set_right(&mut self, value: T) -> T { ... } fn update_left<R>(&mut self, f: impl FnOnce(Option<&mut T>) -> R) -> R { ... } fn update_right<R>(&mut self, f: impl FnOnce(Option<&mut T>) -> R) -> R { ... } fn foreach_mut(&mut self, f: impl FnMut(&mut T)) { ... } fn take_all(&mut self) -> FoldChain<T, Self::OriginalD, Self::Settings> { ... } fn drain(self) -> Drain<'a, T, D, Self> { ... } fn append_all_right( &mut self, chain: FoldChain<T, Self::OriginalD, Self::Settings>, ) { ... } fn append_all_left( &mut self, chain: FoldChain<T, Self::OriginalD, Self::Settings>, ) { ... } fn append_left_from_iter(&mut self, iter: impl Iterator<Item = T>) { ... } fn append_right_from_iter(&mut self, iter: impl Iterator<Item = T>) { ... }
}
Expand description

The trait for mutable views into a FoldChain.

This is a subtrait of FoldChainSlice.

Required Methods§

Source

fn as_mut( self, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, Self::Simplification>

Normalize this view’s type. This is mostly useless.

Source

fn borrow_mut<'b>( &'b mut self, ) -> MutFoldChainSliceStruct<'b, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, Self::Simplification>

Mutably borrow this view.

Provided Methods§

Source

fn mut_view_drop_left_until( self, predicate: impl Fn(&D) -> bool, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, <Self::IsFlushLeft as Bool>::And<Self::IsReversed>, <Self::IsFlushRight as Bool>::And<<Self::IsReversed as Bool>::Not>, T, Self::OriginalD, Self::Settings, Self::Simplification>

Contract this view on the left while the to-be-discarded range’s fold doesn’t meet predicate.

The given predicate must be well-behaved; see Slicing for examples.

This operation’s immutable version is view_drop_left_until and its mirror image is mut_view_drop_right_until.

This is equivalent to self.mut_view_drop(..predicate).

Source

fn mut_view_take_right_until( self, predicate: impl Fn(&D) -> bool, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, <Self::IsFlushLeft as Bool>::And<Self::IsReversed>, <Self::IsFlushRight as Bool>::And<<Self::IsReversed as Bool>::Not>, T, Self::OriginalD, Self::Settings, Self::Simplification>

Restrict this view to the longest range that starts on the right and whose fold doesn’t meet predicate.

The given predicate must be well-behaved; see Slicing for examples.

This operation’s immutable version is view_take_right_until and its mirror image is mut_view_take_left_until.

This is equivalent to self.mut_view_take(predicate..).

Source

fn mut_view_drop_right_until( self, predicate: impl Fn(&D) -> bool, ) -> MutFoldChainSliceStruct<'a, <<Self::IsReversed as Bool>::Not as Bool>::Not, <Self::IsFlushLeft as Bool>::And<<Self::IsReversed as Bool>::Not>, <Self::IsFlushRight as Bool>::And<<<Self::IsReversed as Bool>::Not as Bool>::Not>, T, Self::OriginalD, Self::Settings, Self::Simplification>

Contract this view on the right while the to-be-discarded range’s fold doesn’t meet predicate.

The given predicate must be well-behaved; see Slicing for examples.

This operation’s immutable version is view_drop_right_until and its mirror image is mut_view_drop_left_until.

This is equivalent to self.mut_view_drop(predicate..).

Source

fn mut_view_take_left_until( self, predicate: impl Fn(&D) -> bool, ) -> MutFoldChainSliceStruct<'a, <<Self::IsReversed as Bool>::Not as Bool>::Not, <Self::IsFlushLeft as Bool>::And<<Self::IsReversed as Bool>::Not>, <Self::IsFlushRight as Bool>::And<<<Self::IsReversed as Bool>::Not as Bool>::Not>, T, Self::OriginalD, Self::Settings, Self::Simplification>

Restrict this view to the longest range that starts on the left and whose fold doesn’t meet predicate.

The given predicate must be well-behaved; see Slicing for examples.

This operation’s immutable version is view_take_left_until and its mirror image is mut_view_take_right_until.

This is equivalent to self.mut_view_take(..predicate).

Source

fn mut_view_drop<Predicate: Fn(&D) -> bool, Range: SingleEndedRange<Predicate>>( self, range: Range, ) -> <<Range as SingleEndedRange<Predicate>>::EndIsLeft as Bool>::IfElse<MutFoldChainSliceStruct<'a, <<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not as Bool>::Not, <<Self as FoldChainSlice<'a, T, D>>::IsFlushLeft as Bool>::And<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not>, <<Self as FoldChainSlice<'a, T, D>>::IsFlushRight as Bool>::And<<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not as Bool>::Not>, T, <Self as FoldChainSlice<'a, T, D>>::OriginalD, <Self as FoldChainSlice<'a, T, D>>::Settings, <Self as FoldChainSlice<'a, T, D>>::Simplification>, MutFoldChainSliceStruct<'a, <Self as FoldChainSlice<'a, T, D>>::IsReversed, <<Self as FoldChainSlice<'a, T, D>>::IsFlushLeft as Bool>::And<<Self as FoldChainSlice<'a, T, D>>::IsReversed>, <<Self as FoldChainSlice<'a, T, D>>::IsFlushRight as Bool>::And<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not>, T, <Self as FoldChainSlice<'a, T, D>>::OriginalD, <Self as FoldChainSlice<'a, T, D>>::Settings, <Self as FoldChainSlice<'a, T, D>>::Simplification>>

If range is ..predicate, calls mut_view_drop_left_until(predicate).

If range is predicate.., calls mut_view_drop_right_until(predicate) (You may need to parenthesize predicate in this case).

The given predicate must be well-behaved; see Slicing for examples.

This operation’s immutable version is view_drop.

Source

fn mut_view_take<Predicate: Fn(&D) -> bool, Range: SingleEndedRange<Predicate>>( self, range: Range, ) -> <<Range as SingleEndedRange<Predicate>>::EndIsLeft as Bool>::IfElse<MutFoldChainSliceStruct<'a, <Self as FoldChainSlice<'a, T, D>>::IsReversed, <<Self as FoldChainSlice<'a, T, D>>::IsFlushLeft as Bool>::And<<Self as FoldChainSlice<'a, T, D>>::IsReversed>, <<Self as FoldChainSlice<'a, T, D>>::IsFlushRight as Bool>::And<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not>, T, <Self as FoldChainSlice<'a, T, D>>::OriginalD, <Self as FoldChainSlice<'a, T, D>>::Settings, <Self as FoldChainSlice<'a, T, D>>::Simplification>, MutFoldChainSliceStruct<'a, <<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not as Bool>::Not, <<Self as FoldChainSlice<'a, T, D>>::IsFlushLeft as Bool>::And<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not>, <<Self as FoldChainSlice<'a, T, D>>::IsFlushRight as Bool>::And<<<<Self as FoldChainSlice<'a, T, D>>::IsReversed as Bool>::Not as Bool>::Not>, T, <Self as FoldChainSlice<'a, T, D>>::OriginalD, <Self as FoldChainSlice<'a, T, D>>::Settings, <Self as FoldChainSlice<'a, T, D>>::Simplification>>

If range is ..predicate, calls mut_view_take_left_until(predicate).

If range is predicate.., calls mut_view_take_right_until(predicate) (You may need to parenthesize predicate in this case).

The given predicate must be well-behaved; see Slicing for examples.

This operation’s immutable version is view_take.

Source

fn mut_view_reversed( self, ) -> MutFoldChainSliceStruct<'a, <Self::IsReversed as Bool>::Not, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, Self::Simplification>

Get a reversed version of this view. See Reverse.

This operation’s immutable version is view_reversed.

Source

fn mut_view_with_simplification<NewSimplification: FoldSimplification<T, D>>( self, new_simplification: NewSimplification, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, NewSimplification::ComposeAfterOther<Self::OriginalD, Self::Simplification>>

Compose this view’s current simplification with another one explicitly. See Simplification.

This operation’s immutable version is view_with_simplification.

Source

fn mut_view_simplify<D2: Clone + 'a, Simplifier: for<'x> Fun<&'x D, D2> + Copy + 'a, OP2: Fun<(D2, D2), D2> + Copy + 'a>( self, simplifier: Simplifier, simplified_op: OP2, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, <Self::Simplification as FoldSimplification<T, Self::OriginalD>>::Compose<D2, Simplifier, OP2>>

Simplify this view. See Simplification.

This operation’s immutable version is view_simplify.

Source

fn mut_view_simplify_with_shortcut<D2: Clone + 'a, Simplifier: for<'x> Fun<&'x D, D2> + Copy + 'a, OP2: Fun<(D2, D2), D2> + Copy + 'a, EmptyShortcut: Fun<(), D2> + Copy + 'a, DeltaShortcut: for<'x> Fun<&'x T, D2> + Copy + 'a>( self, simplifier: Simplifier, simplified_op: OP2, empty_shortcut: EmptyShortcut, delta_shortcut: DeltaShortcut, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, <Self::Simplification as FoldSimplification<T, Self::OriginalD>>::ComposeWithShortcut<D2, Simplifier, OP2, EmptyShortcut, DeltaShortcut>>

Simplify this view in a possibly more efficient way. See Simplification.

This operation’s immutable version is view_simplify_with_shortcut.

Source

fn mut_view_unsimplify( self, ) -> MutFoldChainSliceStruct<'a, Self::IsReversed, Self::IsFlushLeft, Self::IsFlushRight, T, Self::OriginalD, Self::Settings, ()>

Remove all simplifications that were applied to this view. See Simplification.

The current simplification of the resulting view will be ().

This operation’s immutable version is view_unsimplify.

Source

fn pop_left(&mut self) -> Option<T>

Remove the leftmost element from this slice.

Returns the removed element, or None, if this slice was already empty.

Source

fn pop_right(&mut self) -> Option<T>

Remove the rightmost element from this slice.

Returns the removed element, or None, if this slice was already empty.

Source

fn append_left(&mut self, value: T)

Append value to the left of this slice.

Source

fn append_right(&mut self, value: T)

Append value to the right of this slice.

Source

fn set_left_or_err(&mut self, value: T) -> Result<T, T>

Replace the leftmost element of this slice with value.

If this slice is empty, this does nothing and returns Err(value).

Otherwise, returns Ok(prev), where prev is the previous leftmost element.

For the unwrapping version, see set_left.

Source

fn set_right_or_err(&mut self, value: T) -> Result<T, T>

Replace the rightmost element of this slice with value.

If this slice is empty, this does nothing and returns Err(value).

Otherwise, returns Ok(prev), where prev is the previous rightmost element.

For the unwrapping version, see set_right.

Source

fn set_left(&mut self, value: T) -> T

Replace the leftmost element of this slice with value and return its previous value.

Panics if this slice is empty.

For the non-panicing version, see set_left_or_err.

Source

fn set_right(&mut self, value: T) -> T

Replace the rightmost element of this slice with value and return its previous value.

Panics if this slice is empty.

For the non-panicing version, see set_right_or_err.

Source

fn update_left<R>(&mut self, f: impl FnOnce(Option<&mut T>) -> R) -> R

Mutate the leftmost element of this slice via a closure, and return the result of the closure.

If this slice is empty, the input of the closure will be None.

Source

fn update_right<R>(&mut self, f: impl FnOnce(Option<&mut T>) -> R) -> R

Mutate the rightmost element of this slice via a closure, and return the result of the closure.

If this slice is empty, the input of the closure will be None.

Source

fn foreach_mut(&mut self, f: impl FnMut(&mut T))

Run a closure on each of this slice’s elements, possibly mutating them, from left to right.

This operation’s immutable version is foreach.

Note that this operation cannot be safely done with an Iterator, because that would allow direct access to mutable references to this data structure’s elements, in a way that might outlive the iterator (so the iterator couldn’t reliably do the proper cleanup/bookkeeping on Drop). An “iterator” capable of this would need to be a streaming iterator instead of an Iterator.

An iterator can iterate over the elements themselves (rather than references), though; see drain or FoldChain’s IntoIterator implementation.

Source

fn take_all(&mut self) -> FoldChain<T, Self::OriginalD, Self::Settings>

Remove all elements from this slice, and return a new FoldChain containing them, in the same order as in this slice’s base FoldChain.

The returned FoldChain will have the same type as this slice’s base.

Source

fn drain(self) -> Drain<'a, T, D, Self>

Convert this slice into an Iterator that removes elements from the left as it emits them (or from the right with DoubleEndedIterator::next_back).

Note that not all elements in this slice will be removed; only those that the iterator emits.

Source

fn append_all_right( &mut self, chain: FoldChain<T, Self::OriginalD, Self::Settings>, )

Append the entire contents of a FoldChain to the right of this slice.

From this slice’s base’s perspective, the elements’ order will be the same as in chain.

Note that chain’s type must be the same as this slice’s base.

Source

fn append_all_left( &mut self, chain: FoldChain<T, Self::OriginalD, Self::Settings>, )

Append the entire contents of a FoldChain to the left of this slice.

From this slice’s base’s perspective, the elements’ order will be the same as in chain.

Note that chain’s type must be the same as this slice’s base.

Source

fn append_left_from_iter(&mut self, iter: impl Iterator<Item = T>)

Append every element from an iterator to the left of this slice.

This is faster than append_lefting them one-by-one, but not asymptotically faster.

Source

fn append_right_from_iter(&mut self, iter: impl Iterator<Item = T>)

Append every element from an iterator to the right of this slice.

This is faster than append_righting them one-by-one, but not asymptotically faster.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, IsReversed: Bool, IsFlushLeft: Bool, IsFlushRight: Bool, T, D: Clone, Settings: FoldSettings<T, D> + 'a, Simplification: FoldSimplification<T, D> + 'a> MutFoldChainSlice<'a, T, <Simplification as FoldSimplification<T, D>>::D2> for MutFoldChainSliceStruct<'a, IsReversed, IsFlushLeft, IsFlushRight, T, D, Settings, Simplification>

Source§

impl<'a, T, D: Clone, Settings: FoldSettings<T, D>> MutFoldChainSlice<'a, T, D> for &'a mut FoldChain<T, D, Settings>