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

Closed
stevenj opened this issue Aug 13, 2024 · 2 comments · Fixed by #16
Closed

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

stevenj opened this issue Aug 13, 2024 · 2 comments · Fixed by #16

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!

This was referenced Jan 28, 2025
@tisonkun
Copy link
Contributor

Provide a patch at #16 that you can test out.

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

Successfully merging a pull request may close this issue.

3 participants