attempted

Crates.ioattempted
lib.rsattempted
version0.1.0
sourcesrc
created_at2022-08-28 14:14:02.868544
updated_at2022-08-28 14:14:02.868544
descriptionWrap a function with 'unwrap or return'
homepage
repositoryhttps://github.com/ChangeCaps/attempted
max_upload_size
id653884
size4,925
Hjalte Nannestad (ChangeCaps)

documentation

https://docs.rs/attempted/latest

README

Attempted

Crates.io Documentation

Examples

fn positive(x: i32) -> Option<i32> {
    if x > 0 {
        Some(x)
    } else {
        None
    }
}

#[attempt]
fn test() {
    // try something
    let x = positive(13)?;
    
    // do something with x
    println!("{} is positive", x);
}
Commit count: 2

cargo fmt