#familiar #flavor #golang #nil #macro #2024 #04

golangify

published at 01.04.2024 this crate brings familiar flavor for newcomers from golang

1 stable release

1.4.24 Apr 1, 2024
0.1.4 Apr 1, 2024

#595 in Rust patterns

Download history 483/week @ 2024-03-29 78/week @ 2024-04-05

561 downloads per month

MIT license

5KB
75 lines

golangify

golangify macro would turn standard rust Result<T,E> into simple, familiar and convenient tuple (T,E);

Example usage

use golangify::*;

fn main() {
    let (res, err) = golangify!(some_func());
    if err != nil {
        println!("{:?}", err);
    }
}

fn some_func() -> Result<u32, &'static str> {
    Err("42")
}

01.04.2024


lib.rs:

#golangify golangify macro would turn standard rust Result<T,E> into simple, familiar and convenient tuple (T,E);

Example usage

use golangify::*;

fn main() {
    let (res, err) = golangify!(some_func());
    if err != nil {
        println!("{:?}", err);
    }
}

fn some_func() -> Result<u32, &'static str> {
    Err("42")
}

01.04.2024

No runtime deps