| Crates.io | pipe-op |
| lib.rs | pipe-op |
| version | 0.0.1 |
| created_at | 2020-10-19 05:54:23.021935+00 |
| updated_at | 2020-10-19 05:54:23.021935+00 |
| description | The elixir pipe operator as a macro in Rust |
| homepage | |
| repository | https://github.com/mcraealex/pipe-op |
| max_upload_size | |
| id | 302779 |
| size | 11,000 |
Implementation of the pipe operator in Rust as a macro.
I wrote this because of 3 main things:
pipe!(
value,
function1(args),
function2(args)?, // notice the operator here
function3(args).await
)
The pipe operator is common in languages like elixir and haskell, they provide clarity and convience.
conn
|> send_resp(404, "Not found")
The argument will always go into the first function or method call.
pipe!(value, a.f().m()) // is equivalent to a.f(value).m()
To get around this we can make it a closure and pass the arg where we want.
pipe!(value, {|x| a.f().m(x)}()) // is equivalent to a.f().m(value)