Some time ago I remember people bringing up that Rust tends to favour performance over ergonomics and accessibility, with dyn Trait
-s, their vtables and downcasting on demand, (generally) frowned upon - as static compile-time dispatch tends be quite a bit faster.
I also vaguely remember someone bringing up that one could, effectively, recreate their own Python/Lua/JS in Rust - by simply wrapping everything up in Rc<RefCell<?>>
or Arc<Mutex<?>>
, depending on the case at hand. Assuming one has considered all the performance applications, the reasons why it's discouraged / not recommended / unnecessary you name it, I am rather curious.
Why have the smart pointers been restricted from Copy
? Perhaps a more general question would be in order for the implementation / restrictions on the Copy
itself, which explicitly states that:
Generalizing the latter case, any type implementing
Drop
can’t beCopy
, because it’s managing some resource besides its ownsize_of::<T>
bytes.
Not sure I understand the full reasoning behind it. What's so problematic about declaring a type with an inner (A)Rc<T>
, and making it automatically clone()
itself via a #[derive(Clone, Copy)]
on each move? Why is there any need to care whether any additional resources are being managed? Whether or not a Drop
has to be called, at the end of a lifetime?
There are two RFCs (one and two) that seem to have already brought a rather substantial amount of attention on the matter. Yet even after reading them, I don't understand the "why".