vec2

Macro vec2 

Source
macro_rules! vec2 {
    () => { ... };
    ($val:expr) => { ... };
    ($x:expr, $y:expr) => { ... };
}
Expand description

Utility macro for creating a vector from the given arguments.

§Examples

You can create default (i.e., “zero length”) vectors with this macro:

use rustvision::vec::*;

let v = vec2![];
assert_eq!(v, Vec2 { x: 0, y: 0 });

It also supports “prefilling” all fields of a vector with a given value:

use rustvision::vec::*;

let v = vec2![42];
assert_eq!(v, Vec2 { x: 42, y: 42 });

Lastly, it supports intuitive vector initialization aswell:

use rustvision::vec::*;

let v = vec2![42, 1337];
assert_eq!(v, Vec2 { x: 42, y: 1337 });

This macro is also “type agnostic” in a way, that automatically creates a vector of the fitting utility type (e.g., Vec2d) when called with the right arguments.