You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[throws(Error)]fnfoo(a:Option<u8>) -> u8{letSome(a) = a else{return0;};
a
}
does not work.
You need to do
#[throws(Error)]fnfoo(a:Option<u8>) -> u8{letSome(a) = a else{returnOk(0);};
a
}
to make it compile.
In contrast, there is no need for this Ok(...) if you use if let - else:
#[throws(Error)]fnfoo(a:Option<u8>) -> u8{ifletSome(a) = a {
a
}else{return0;}}
But I mean, let-else breaks even rustfmt (I had to manually format the code) and github syntax highlighting (else in the first code snippet does not get highlighted as a keyword, return does not get highlighted in the first two), so yeah, a breakage in a 2yo procmacro is not really surprising. (Wonder if using a separate keyword like guard would be a better decision or having to bump the edition again would be to much of a hustle.)
Anyways, nice article (and the whole blog too): https://without.boats/blog/why-ok-wrapping/
Btw, do you happen to know if any progress has been made on this feature in rust proper over the last two years since the blogpost? I, personally, would love to see this in Rust, but from what I can tell, it's a bit controversial with some people and definitely does not seem to be a high priority for the language right now.
The text was updated successfully, but these errors were encountered:
Nemo157
added a commit
to Nemo157/culpa
that referenced
this issue
Jun 29, 2023
does not work.
You need to do
to make it compile.
In contrast, there is no need for this
Ok(...)
if you useif let - else
:But I mean, let-else breaks even rustfmt (I had to manually format the code) and github syntax highlighting (
else
in the first code snippet does not get highlighted as a keyword,return
does not get highlighted in the first two), so yeah, a breakage in a 2yo procmacro is not really surprising. (Wonder if using a separate keyword likeguard
would be a better decision or having to bump the edition again would be to much of a hustle.)Anyways, nice article (and the whole blog too):
https://without.boats/blog/why-ok-wrapping/
Btw, do you happen to know if any progress has been made on this feature in rust proper over the last two years since the blogpost? I, personally, would love to see this in Rust, but from what I can tell, it's a bit controversial with some people and definitely does not seem to be a high priority for the language right now.
The text was updated successfully, but these errors were encountered: