Skip to main content

rect

Macro rect 

Source
macro_rules! rect {
    ($tl: expr, $br: expr) => { ... };
    ($l:expr, $t:expr, $r:expr, $b:expr) => { ... };
}
Expand description

A macro that creates a rectangle with the given coordinates.

Unlike Rect::from_tlbr or Rect::from_ltrb, this macro is infallible as it guarantees that the coordinates form a valid rectangle, by re-arranging them if necessary; i.e. swapping either the left and right coordinates, or the top and bottom coordinates.

ยงExamples

use ixy::{rect, Pos};

let rect_ltrb = rect!(1, 2, 3, 4);
let rect_tlbr = rect!(Pos::new(1, 2), Pos::new(3, 4));