4 ms·
> I would think the Err(err) => return Err(err) line needlessly constructs a copy of result It sounds like this is coming from a C++ bias? So please forgive me
by throwaway234232 4y ago
> I would think the Err(err) => return Err(err) line needlessly constructs a copy of result
It sounds like this is coming from a C++ bias? So please forgive me if this is wrong.
Rust, in my experience, favors move semantics first, then copy semantics after.
I know in C++, we had implicit copy constructors, with move semantics after with rvalue references, where you need to use `std::move` in a lot of cases.
So what helps, in my opinion, is to think of Rust as using `std::move` as a default.
- saghm 4y ago> So what helps, in my opinion, is to think of Rust as using `std::move` as a default Even more than that, with the exception of types that implement `Copy` (e.g. bools, integers, etc.), using after a move won't just silently degrade to a copy, but will cause a compiler error. Copying is required to be explicit for all but the most trivial types.