4 ms·
Clone is not "butchering idiomatic Rust", we gotta stop this nonsense
by ramon156 5mo ago
Clone is not "butchering idiomatic Rust", we gotta stop this nonsense
- jdw64 5mo agoSorry, should clarify. .clone() itself isn't inherently unidiomatic when used . My issue is specifically with how the AI uses it. In AI code, .clone() is almost always used as a brute-force escape hatch
- andai 5mo agoSo .clone() significantly reduces the mental overhead of using rust with a small performance impact? I'm intrigued :) Maybe it's harder to reason about the lifetime semantics while also writing code, and works better as a second phase (the de-cloning).
- _verandaguy 5mo ago> So .clone() significantly reduces the mental overhead of using rust with a small performance impact? I'm intrigued :) No, the performance impact will depend on `impl Clone` for the underlying type, the hotness of the code path, and how sensitive to those two variables your code's domain is. It may be extremely expensive. > Maybe it's harder to reason about the lifetime semantics while also writing code, and works better as a second phase (the de-cloning). There are cases where assuming `clone` is possible allows for significant architectural and API simplifications at the expense of performance. In those cases, de-cloning will be involved and may produce significant changes.
- izietto 5mo agoJust like for me as an amateur Rust enjoyer then
- pjmlp 5mo agoWell, some of us rather use languages with automatic resource management in the type system, in whatever form, and thus avoid typing .clone() all over the place.