Trait SlicePermute

Source
pub trait SlicePermute<T>: Slice<Item = T> {
    // Required methods
    const fn bit_rev_permutation(&mut self);
    const fn digit_rev_permutation(&mut self, radix: usize);
    const fn grey_code_permutation(&mut self);
}

Required Methods§

Source

const fn bit_rev_permutation(&mut self)

Performs the bit-reverse permutation. Length must be a power of 2.

§Example
use slice_ops::ops::*;
 
let mut arr = [0b000, 0b001, 0b010, 0b011, 0b100, 0b101, 0b110, 0b111];
 
arr.bit_rev_permutation();
 
assert_eq!(arr, [0b000, 0b100, 0b010, 0b110, 0b001, 0b101, 0b011, 0b111])
Source

const fn digit_rev_permutation(&mut self, radix: usize)

Performs the digit-reverse permutation with any radix. Length must be a power of the radix.

§Example
use slice_ops::ops::*;
 
let mut arr = [0b000, 0b001, 0b010, 0b011, 0b100, 0b101, 0b110, 0b111];
 
arr.digit_rev_permutation(2);
 
assert_eq!(arr, [0b000, 0b100, 0b010, 0b110, 0b001, 0b101, 0b011, 0b111])
Source

const fn grey_code_permutation(&mut self)

Performs the grey code permutation. Length must be a power of 2.

§Example
use slice_ops::ops::*;
 
let mut arr = [0b000, 0b001, 0b010, 0b011, 0b100, 0b101, 0b110, 0b111];
 
arr.as_mut_slice().grey_code_permutation();
 
assert_eq!(arr, [0b000, 0b001, 0b011, 0b010, 0b110, 0b111, 0b101, 0b100])

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.

Implementations on Foreign Types§

Source§

impl<T> SlicePermute<T> for [T]

Implementors§