Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> So apparently these functions intend to consume x.

I guess in that case I don't really get the complaint. If there's a good reason for f or g to consume x, I would think I would always want the copy to be explicit. But I could still be missing some subtlety I guess.



Rust can be like this, because it tends to expose a lot of information, and not everyone cares about every type of information.


The common scenario for f and g to consume x is that x is a smart pointer type e.g. Rc/Arc.

to make it clear that the clone is "cheap", some Rust developer prefer using `Arc::Clone(&x)` over `x.clone()`.


Yeah, it feels reasonable to me, but I'm a happy Rust programmer, perhaps if you're mostly working in functional languages this feels very wrong, I would not know.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: