Swap

Trait Swap 

Source
pub trait Swap {
    type Error;
    type Input;

    // Required method
    fn swap(&mut self, input: Self::Input) -> Result<(), Self::Error>;
}
Expand description

See Swap::swap for more information.

Required Associated Types§

Source

type Error

Error

Source

type Input

Input

Required Methods§

Source

fn swap(&mut self, input: Self::Input) -> Result<(), Self::Error>

Swaps two elements referencied by Input.

Implementations on Foreign Types§

Source§

impl<T> Swap for &mut [T]

let mut structure = cl_aux::doc_tests::slice_mut!();
cl_aux::Swap::swap(&mut structure, [0, 2]);
assert_eq!(structure.get(0), Some(&3));
assert_eq!(structure.get(2), Some(&1));
Source§

type Error = Error

Source§

type Input = [usize; 2]

Source§

fn swap(&mut self, [a, b]: Self::Input) -> Result<(), Self::Error>

Source§

impl<T> Swap for &mut T
where T: Swap,

Source§

type Error = <T as Swap>::Error

Source§

type Input = <T as Swap>::Input

Source§

fn swap(&mut self, input: Self::Input) -> Result<(), Self::Error>

Source§

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

let mut structure = cl_aux::doc_tests::array();
cl_aux::Swap::swap(&mut structure, [0, 2]);
assert_eq!(structure.get(0), Some(&3));
assert_eq!(structure.get(2), Some(&1));
Source§

type Error = Error

Source§

type Input = [usize; 2]

Source§

fn swap(&mut self, [a, b]: Self::Input) -> Result<(), Self::Error>

Implementors§