4 ms·
It's a bit annoying that there is a standard desugaring of all of this, but there's no actual way of implementing this sugaring yourself. I guess you could have
by writebetterc 1y ago
It's a bit annoying that there is a standard desugaring of all of this, but there's no actual way of implementing this sugaring yourself. I guess you could have a token macro (or whatever they're called) at the top scope and do it yourself?
Anyway, my conclusion is that in order to learn Rust you can't use any syntactic sugar the language provides, those are 'expert features'. There's no way I'd be able to figure out why this happens. Do rust-analyzer provide a way of desugaring these constructs?
- steveklabnik 1y ago> there's no actual way of implementing this sugaring yourself. This is the common case in languages with sugar. Heck, you could consider all of Rust sugar for MIR... > There's no way I'd be able to figure out why this happens. You don't generally need to, but most of this is documented: https://doc.rust-lang.org/stable/std/iter/index.html#for-loops-and-intoiterator https://doc.rust-lang.org/stable/std/iter/index.html#for-loo... https://doc.rust-lang.org/stable/std/ops/trait.Add.html#implementing-add-with-generics https://doc.rust-lang.org/stable/std/ops/trait.Add.html#impl... ?'s desugaring isn't documented because the desugaring is subject to change.