-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Unwrap macro #273
Unwrap macro #273
Conversation
Thanks for building a PoC. unwrap!(x.
map(|z| z + 1).
then(something)
) I don't get type annotations next to each method call or in internal closures. To work around the issue I would split the chain into its own variable: let res = x.
map(|z| z + 1).
then(something);
unwrap!(res) But then I won't get the chain expression printed in the panic message (if the unwrap fails) and the reported location will be sort of "off by one line" (but still be more precise than with the |
@Dirbaio the team discussed how we'd like to implement this feature and we are OK with a macro implementation so I'll review this PR once you mark it as ready for review. |
DOne :D |
I don't know what's up with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
I don't know what's up with the unused import: crate as defmt from CI.
I think that's because internp!
requires it when target = x86 but not when target = ARM. Sticking an allow
on it would be an OK fix.
.into() | ||
} | ||
|
||
fn ident_expr(name: &str) -> Expr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice refactor 👍
This is a PoC of the
unwrap!
macro discussed in #161, to see how well it works.Seems to work great, line numbers are printed correctly. The only drawback is the syntax is less nicer than the normal
unwrap()
since it doesn't read left-to-right.Ignore the
Escape braces in assert expressions.
commit, it's included so the unwrap macro can use theescape_expr
function.