Skip to main content

BlockDim

Trait BlockDim 

Source
pub trait BlockDim: Clone {
    const SHIFT: usize;
    const WIDTH: usize = _;
    const AREA: usize = _;
    const MASK: usize = _;

    // Provided method
    fn round_up_to_valid(rows: usize, cols: usize) -> (usize, usize) { ... }
}
Expand description

A type that represents compile time block dimensions.

Required Associated Constants§

Source

const SHIFT: usize

Number of left shifts of 1 for value.

Provided Associated Constants§

Source

const WIDTH: usize = _

Width and height of 2D block.

Source

const AREA: usize = _

Number of elements in 2D block.

Source

const MASK: usize = _

Bitmask for value.

Provided Methods§

Source

fn round_up_to_valid(rows: usize, cols: usize) -> (usize, usize)

Rounds up dimensions to next valid size. Returns (rows, cols).

§Example
use block_grid::{BlockDim, U4};

// (3, 10) are not valid dimensions for a block size of 4
let new_valid = U4::round_up_to_valid(3, 10);
// (4, 12) are the returned valid dimensions
assert_eq!(new_valid, (4, 12));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§