Skip to main content

FromCoarserIndex

Trait FromCoarserIndex 

Source
pub trait FromCoarserIndex<T>
where T: Ord + From<usize>,
{ // Required methods fn min_from(coarser: T) -> usize; fn max_from_(coarser: T) -> usize; // Provided methods fn max_from(coarser: T, len: usize) -> usize { ... } fn inclusive_range_from(coarser: T, len: usize) -> RangeInclusive<usize> where T: Clone { ... } }
Expand description

Maps coarser-grained indices to ranges of finer-grained indices.

Useful for hierarchical index systems where one index type represents a range of another (e.g., mapping hour indices to timestamp ranges).

Required Methods§

Source

fn min_from(coarser: T) -> usize

Returns the minimum fine-grained index represented by the coarse index.

Source

fn max_from_(coarser: T) -> usize

Returns the maximum fine-grained index represented by the coarse index. Note: May exceed actual data length - use max_from for bounded results.

Provided Methods§

Source

fn max_from(coarser: T, len: usize) -> usize

Returns the maximum fine-grained index, bounded by the data length. Returns 0 if len is 0 (empty data).

Source

fn inclusive_range_from(coarser: T, len: usize) -> RangeInclusive<usize>
where T: Clone,

Returns the inclusive range of fine-grained indices for the coarse index. Returns an empty range (1..=0) if len is 0.

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§