fn_block Crate
Library defining macros for calling blocks or expressions in a closure.
Quick Introduction
This library was mostly written to allow "safe navigation" with the ?. operator combination
(seemingly) without jumping out of the current function. This allows a similar use of the operator
as in other languages (such as Swift, C# or Kotlin).
To use this library, you have to add it to the dependencies of your Cargo.toml file
[]
= "0.1.0"
Then add the following lines to your module:
extern crate fn_block;
use *;
Instead of the wildcard, you can also just import the symbols you need.
Here is an example on how to use the crate:
let o = Some;
let s = fn_expr!;
assert_eq!;
As soon as the API documentation is published, a link to the crate documentation will be added here.
Functionality Overview
In short, this crate provides the following APIs:
- The
fn_exprmacro allows wrapping an expression into a lambda that is directly called. - The
fn_blockmacro allows wrapping a block into a lambda that is directly called. - The
IntoSometrait, which is implemented for allSizedtypes, allows to callinto_someon a value to move it into anOption::Some. - The
IntoOktrait, which is implemented for allSizedtypes, allows to callinto_okon a value to move it into anResult::Ok.
As soon as the API documentation is published it will be updated here.
For more examples, please have a look at the test module.
License
The fn_block crate is licensed under the following licenses:
- Apache License, Version 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT / http://opensource.org/licenses/MIT)
Choose under which you want to use the library.