Skip to main content

window

Macro window 

Source
macro_rules! window {
    ($side:expr) => { ... };
}
Expand description

An OddWindowSide literal, checked at compile time.

Named for the call site rather than the type: what a caller writes is a window size, and window!(31) beside a bias argument reads as one. The type keeps the longer name because it is one axis, which is the thing a reader of the signature has to know.

The sigma! macro’s counterpart for window sides; see it for why this is a macro and not a const fn. A value that is not a constant expression does not compile (error[E0435]); use OddWindowSide::try_new there.

§Example

use fovea::{OddWindowSide, window};

const LOCAL: OddWindowSide = window!(31);
assert_eq!(LOCAL.radius(), 15);
assert_eq!(window!(1).get(), 1); // valid and degenerate

An even side has no centre pixel, so it does not build:

use fovea::window;
// ERROR: evaluation panicked: window side must be odd and non-zero
let _ = window!(16);