Add builder functions to GeglOperations to more easily construct them.

This commit is contained in:
Bauke 2024-01-28 14:04:55 +01:00
parent 190527d761
commit 5fb4ed793c
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 18 additions and 0 deletions

View File

@ -18,6 +18,7 @@ workspace = true
[dependencies]
indexmap = "2.1.0"
paste = "1.0.14"
[dev-dependencies]
insta = "1.34.0"

View File

@ -23,6 +23,23 @@ macro_rules! gegl_operation {
)*
}
paste::paste! {
impl $struct_name {
$(
#[doc = concat!(" Builder function to assign `", stringify!($key), "`.")]
pub fn [<with_ $key>](mut self, value: $key_type) -> $struct_name {
self.$key = value;
self
}
)*
/// Get this operation inside a [`Box`].
pub fn boxed(self) -> Box<$struct_name> {
Box::new(self)
}
}
}
impl Default for $struct_name {
fn default() -> $struct_name {
$struct_name {