fix(apb): bool setter/getter with rename
This commit is contained in:
parent
bdf48bb7cb
commit
a615b5d4e8
1 changed files with 17 additions and 0 deletions
|
@ -115,6 +115,12 @@ macro_rules! getter {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
($name:ident::$rename:ident -> bool) => {
|
||||||
|
fn $name(&self) -> Option<bool> {
|
||||||
|
self.get(stringify!($rename))?.as_bool()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
($name:ident::$rename:ident -> &str) => {
|
($name:ident::$rename:ident -> &str) => {
|
||||||
fn $name(&self) -> Option<&str> {
|
fn $name(&self) -> Option<&str> {
|
||||||
self.get(stringify!($rename))?.as_str()
|
self.get(stringify!($rename))?.as_str()
|
||||||
|
@ -206,6 +212,17 @@ macro_rules! setter {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
($name:ident::$rename:ident -> bool) => {
|
||||||
|
paste::item! {
|
||||||
|
fn [< set_$name >](mut self, val: Option<bool>) -> Self {
|
||||||
|
$crate::macros::set_maybe_value(
|
||||||
|
&mut self, stringify!($rename), val.map(|x| serde_json::Value::Bool(x))
|
||||||
|
);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
($name:ident -> &str) => {
|
($name:ident -> &str) => {
|
||||||
paste::item! {
|
paste::item! {
|
||||||
fn [< set_$name >](mut self, val: Option<&str>) -> Self {
|
fn [< set_$name >](mut self, val: Option<&str>) -> Self {
|
||||||
|
|
Loading…
Reference in a new issue