Expand description
§Piperize
inspired by elixir’s pipe functions this gets rid of the boilerplate of writing a new trait if you want to create a dot method on some type
§Before:
pub trait FooThis {
fn foo_this(self) -> i32;
}
impl FooThis for i32 {
fn foo_this(self) -> i32 {
self + self
}
}
fn main() {
let foo = 21.foo_this();
assert_eq!(foo, 42);
}§After:
#[piperize::piperize]
fn foo_this(input: i32) -> i32 {
input + input
}
fn main() {
let foo = 21.foo_this();
assert_eq!(foo, 42);
}§Using multiple arguments:
#[piperize::piperize]
fn my_add(a: i32, b: i32) -> i32 {
a + b
}
fn main() {
let foo = 21.my_add(21);
assert_eq!(foo, 42);
}