4 ms·
The operator overloading is nice but you still get smacked in the face right away by the borrow checker. Simple stuff like this won't compile ("use of moved val
by millstone 6y ago
The operator overloading is nice but you still get smacked in the face right away by the borrow checker. Simple stuff like this won't compile ("use of moved value"):
let a = Integer::from(10);
let b = a + a;
- smmalis37 6y agolet b = &a + &a; will work, but I agree it's unfortunate that this is necessary.
- pimeys 6y agoThis would work if `Integer` would implement the `Copy` trait. But I guess that type is heavy enough for it to be too expensive, therefore forcing you to explicitly call `clone()`.
- Measter 6y agoThat `Integer` type can't implement `Copy` because it manages a resource, meaning you can't just do a simple memcpy of the type.