|
|
|
|
|
by throwaway234232
1444 days 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. |
|
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.