(no title)
fkcgnad | 2 years ago
Rust Has this with "match" but only via a single ref.
You would have to make alternative restructuring syntax to go into the match expression if you want it to work.
Hypothetically:
fn g(v: Option<i32>) -> Option<Option<i32>> {
match v {
Some(_Some(_Some(x))),
None(_None)
}
}
Any character with an underscore is a "restructuring" syntax here. Rust only does restructuring with references via the ref keyword and it only does it once per var per expression. The syntax I presented here is hypothetical of course.I would say it's more syntactic sugar as you can do the restructuring on the right side of the match expression. You can make up an entire functional language using this technique and eliminate the => and everything after it.
I largely agree with you that it's not exactly necessary to do this. Arguably it makes things harder to read.
No comments yet.