News for hackers. Stuff that matters.
Re:Rust 1.49.0 by option_greek on Thursday December 31, 2020 @10:54AM (#25593761)
-> specifically this one: "Reborrowing, &*s"

Would have been easier to implement with a copy constructor I guess. Why not implicitly clone in some cases (since classes like String gets used so frequently).

Re:Rust 1.49.0 by steveklabnik on Thursday December 31, 2020 @10:57AM (#25593795)
Well, Rust doesn't have constructors, let alone copy constructors. Clone goes from &T -> T, so that is the exact opposite conversion needed here, let alone auto-clone.

Automatically copying strings may not be a great idea: https://news.ycombinator.com/item?id=8704318

Re:Rust 1.49.0 by shadow31 on Thursday December 31, 2020 @05:27PM (#25597906)
> Why not implicitly clone in some cases (since classes like String gets used so frequently)

Because they get used so frequently. Why would we want to add expensive clones to frequently used operations?

This would be like asking why LINQ methods in C# aren't deferred by default. Yes, there's a few situations where that would be nice but it would make the functions largely useless because of how poor performance would be.