#error-handling #ok #replacing #approach

no-std okk

Yet another approach to replacing the Ok(())

1 unstable release

0.1.0 Nov 28, 2024

#1769 in Rust patterns

Download history 84/week @ 2024-11-22 48/week @ 2024-11-29 2/week @ 2024-12-06

134 downloads per month

MIT/Apache

6KB

okk

This crate is yet another approach to replacing Ok(()) across the code, following the idea discussed in this IRLO thread.

Use case

This crate provides a function ok() and a macro ok!(), both can be used to replace Ok(()), and so you can write only one pair of parentheses:

use okk::*;

struct MyError;

fn try_foo() -> Result<(), MyError> {
    // ...
    ok()
}

fn try_bar() -> Result<(), MyError> {
    // ...
    ok!()
}

No runtime deps