5 ms·
But why add a language feature (and a new symbol, even!) when by definition you can always fix the issue by shadowing the original variable and pointing it at t
by zozbot234 1y ago
But why add a language feature (and a new symbol, even!) when by definition you can always fix the issue by shadowing the original variable and pointing it at the new location? At most, this calls for a change in compiler diagnostics to add a hint in cases that are trivially fixable.
- jiggawatts 1y agoThere are scenarios where retrieving the just-inserted value without first cloning it isn't possible. E.g.: when inserting a value into a non-empty hashset and then needing it again immediately. But yeah... that's a bit of a contrived example and can be solved by a simple change to the insert function without specialised support from the language.
- estebank 1y agoIt sounds like you'd want the entry API: https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.entry https://doc.rust-lang.org/std/collections/struct.HashMap.htm...