Crates.io | curmacro |
lib.rs | curmacro |
version | 1.0.0 |
source | src |
created_at | 2023-02-13 19:53:30.388272 |
updated_at | 2023-02-13 19:53:30.388272 |
description | Crate with usefull macros like struct getters and setters creation macros |
homepage | https://github.com/CURVoid/curmacro.git |
repository | https://github.com/CURVoid/curmacro.git |
max_upload_size | |
id | 784223 |
size | 15,102 |
Crate with usefull macros like struct getters and setters creation macros
use curmacro::*;
struct Point {
pub x: i32,
pub y: i32
}
impl Point {
getters!(
pub get_x(x) -> i32;
pub get_y(y) -> i32;
);
setters!(
pub set_x(i32) -> x;
pub set_y(i32) -> y;
);
}
let x = 13;
let y = 215;
let mut point = Point { x, y };
assert_eq!(point.get_x().clone(), x);
assert_eq!(point.get_y().clone(), y);
let x = 993;
let y = 37;
point.set_x(x);
point.set_y(y);
assert_eq!(point.get_x().clone(), x);
assert_eq!(point.get_y().clone(), y);