Skip to content

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mayhaps

GitHub Stars GitHub Issues Current Version

Convenience macros for those uncertain times.


Buy me a coffee

Whether you use this project, have learned something from it, or just like it, please consider supporting it by buying me a coffee, so I can dedicate more time on open-source projects like this :)

Buy Me A Coffee


Usage

The crate exports one macro, maybe!. It runs a block when an Option holds a value, binding the unwrapped value to the given name:

use mayhaps::maybe;

let opt = Some(5);
maybe!(val from (opt) exists {
    println!("got {}", val); // runs only when opt is Some
});

An else variant runs a second block when the Option is empty:

use mayhaps::maybe;

let opt: Option<i32> = None;
maybe!(val from (opt) exists {
    println!("got {}", val);
} else {
    println!("nothing there"); // runs when opt is None
});

License

You can check out the full license here

This project is licensed under the terms of the MPL-2.0 license.

About

Rust macros for uncertain times

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages