> Rust doesn't have syntax to mark a struct field as being in a borrowed state.
> ast_nodes: Vec<&'Self::source str>,
Oh, that would be neat to replace the https://github.com/tommie/incrstruct I wrote for two-phase initialization. Unlike Ouroboros and self_cell, it uses traits so the self-references can be recreated after a move. Whether it's a good idea, I don't know, but the magic Ouroboros applies to my struct feels wrong. But I say that as someone coming from C++.
> if let Some(x) = some_var && some_expr { }
Coming from Go, I was surprised that something like
`if some_var.is_some_and(|x| some_expr)` is the current way to do that. It is less flexible and doesn't actually bind `x` into the conditional body (hence the proposal) but works today.
I personally use two conditionals for such case. Yes, I might have written Rust too long to say this but it is more like a minor ergonomic fix and any solution should be generalizable into other use cases. The eventually accepted syntax, `if let PAT = EXPR {&& EXPR}` [1], is okay by itself but not (yet) generalized and that's my current complaint about it. The whole `{let PAT = EXPR &&} EXPR` should have been a valid expression in my opinion. (This exact suggestion is not in the RFC, the closest would be making `let PAT = EXPR` a boolean expression which really looks like a mistake.) Maybe I should check whether this was ever suggested...
> I personally use two conditionals for such case.
Me too. But that often makes my logic worse. Its quite common to want to share the same code in the else branch, for example:
if let Some(val) = opt {
if expr {
// ....
} else {
do_complex_stuff();
}
} else {
do_complex_stuff();
}
I don't want to copy+paste that complex code in two places. And you can fix that in turn with a named block & named break statements or a function - but .... whyyyyy? Why is this even a thing? The solution is so obvious. The RFC you linked to fix it is fine, and 6 years old now. My sister has a child in grade school who was born after that RFC was drafted.
Yes, you can work around this hole in the language any number of ways with ugly code. But I don't want to do that. I want to use a good language.
I'm worried that you want a "good" language at any circumstance, which is not even generally possible but also at odds with other aspects of languages. This still counts as minor for me because it is just slightly annoying and doesn't make something impossible or much harder to read (and the readability varies enough that this threshold is much higher than this case).
> I'm worried that you want a "good" language at any circumstance, which is not even generally possible but also at odds with other aspects of languages.
Yes, I do want a good programming language. I agree its relatively minor compared to the other issues I talked about in the blog post.
In what way is this at odds with other aspects of the language? If its at odds with the rest of the language, why is this feature being added?
> ast_nodes: Vec<&'Self::source str>,
Oh, that would be neat to replace the https://github.com/tommie/incrstruct I wrote for two-phase initialization. Unlike Ouroboros and self_cell, it uses traits so the self-references can be recreated after a move. Whether it's a good idea, I don't know, but the magic Ouroboros applies to my struct feels wrong. But I say that as someone coming from C++.
> if let Some(x) = some_var && some_expr { }
Coming from Go, I was surprised that something like
isn't a thing.