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 |
japaric
left a comment
There was a problem hiding this comment.
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 { |
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_exprfunction.