News for hackers. Stuff that matters.
Re:Beginner's guide to error handling in Rust by throwaway234232 on Sunday July 10, 2022 @02:00PM (#32047122)
> 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.

Re:Beginner's guide to error handling in Rust by saghm on Sunday July 10, 2022 @03:07PM (#32047848)
> 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.