Make set_get! macro usable with types module

This commit is contained in:
5ohue
2024-05-11 12:59:39 +03:00
parent 64bd81acd2
commit 48e0452e74
3 changed files with 8 additions and 60 deletions

View File

@ -110,10 +110,10 @@ macro_rules! set_get {
($($get:ident, $set:ident, $c_get:ident, $c_set:ident, $typ:ty )*) => {
$(
pub fn $get(&self) -> $typ {
unsafe { ::bindings::$c_get(self.wand) }
unsafe { ::bindings::$c_get(self.wand).into() }
}
pub fn $set(&mut self, v: $typ) -> Result<()> {
match unsafe { ::bindings::$c_set(self.wand, v) } {
match unsafe { ::bindings::$c_set(self.wand, v.into()) } {
::bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err(MagickError(concat!(stringify!($set), " returned false")))
}