-
Notifications
You must be signed in to change notification settings - Fork 34
Allow specifying result labels for enum variants #61
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
Changes from 1 commit
6ce2de0
2f913a6
3352b7c
1a199d8
5cf0228
e3381ce
78f8588
8c8175e
1b3931d
2175ccc
dba8214
3df90d4
4621282
6b1869a
4e67714
b88cff3
fccbe70
f5182a3
2ff0388
a0acdc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This change is necessary to make spez work, otherwise the compiler gets confused about the specialization to choose in the spez::Match<i> generated traits. The issue is not spez-specific, as the macro is simple sugar over the auto-deref specialization trick in general. This commit is also the "maximalist" solution to #74, as it simply ignores the return type if it has syntax incompatible with the context we want to use. Closes: #74 Co-Authored-By: Anthony Deschamps <[email protected]>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,7 +237,7 @@ macro_rules! result_labels { | |
| $crate::__private::spez! { | ||
gagbo marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better if we could call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Calling the function Generating the |
||
| for val = $e; | ||
|
|
||
| match<T: GetLabels, E: GetLabels> &Result<T, E> -> Option<ResultAndReturnTypeLabels> { | ||
| match<T, E> &::std::result::Result<T, E> where T: GetLabels, E: GetLabels -> ::std::option::Option<ResultAndReturnTypeLabels> { | ||
| match val { | ||
| Ok(ok) => Some(( | ||
| ok.__autometrics_get_labels().unwrap_or(OK_KEY), | ||
|
|
@@ -250,7 +250,7 @@ macro_rules! result_labels { | |
| } | ||
| } | ||
|
|
||
| match<T, E: GetLabels> &Result<T, E> -> Option<ResultAndReturnTypeLabels> { | ||
| match<T, E> &::std::result::Result<T, E> where E: GetLabels -> ::std::option::Option<ResultAndReturnTypeLabels> { | ||
| match val { | ||
| Ok(ok) => Some(( | ||
| OK_KEY, | ||
|
|
@@ -263,7 +263,7 @@ macro_rules! result_labels { | |
| } | ||
| } | ||
|
|
||
| match<T: GetLabels, E> &Result<T, E> -> Option<ResultAndReturnTypeLabels> { | ||
| match<T, E> &::std::result::Result<T, E> where T: GetLabels -> ::std::option::Option<ResultAndReturnTypeLabels> { | ||
| match val { | ||
| Ok(ok) => Some(( | ||
| ok.__autometrics_get_labels().unwrap_or(OK_KEY), | ||
|
|
@@ -276,7 +276,7 @@ macro_rules! result_labels { | |
| } | ||
| } | ||
|
|
||
| match<T, E> &Result<T, E> -> Option<ResultAndReturnTypeLabels> { | ||
| match<T, E> &::std::result::Result<T, E> -> ::std::option::Option<ResultAndReturnTypeLabels> { | ||
| match val { | ||
| Ok(ok) => Some(( | ||
| OK_KEY, | ||
|
|
@@ -289,11 +289,11 @@ macro_rules! result_labels { | |
| } | ||
| } | ||
|
|
||
| match<T: GetLabels> &T -> Option<ResultAndReturnTypeLabels> { | ||
| match<T> &T where T: GetLabels -> ::std::option::Option<ResultAndReturnTypeLabels> { | ||
| val.__autometrics_get_labels().map(|label| (label, val.__autometrics_static_str())) | ||
| } | ||
|
|
||
| match<T> T -> Option<ResultAndReturnTypeLabels> { | ||
| match<T> T -> ::std::option::Option<ResultAndReturnTypeLabels> { | ||
| None | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.