Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would be nice to have some and none like ok and err #11

Open
stevenj opened this issue Aug 13, 2024 · 1 comment
Open

Would be nice to have some and none like ok and err #11

stevenj opened this issue Aug 13, 2024 · 1 comment

Comments

@stevenj
Copy link

stevenj commented Aug 13, 2024

It would be cool to have equivalents to ok and err for some and none results.

So like this:

/// Logs `Some` results at the `info` level and `None` results at the `error` level.
#[logcall(some = "info", none = "error")]
fn divide(a: i32, b: i32) -> Option<i32> {
    if b == 0 {
        None
    } else {
        Some(a / b)
    }
}

And conversely, if only some is specified, it would not log on None or vice versa.

@andylokandy
Copy link
Collaborator

Good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants