News for hackers. Stuff that matters.
Re:Announcing Rust 1.13 by stjepang on Friday November 11, 2016 @05:15AM (#12929386)
Yes, there is a simpler approach.

If your function returns Result<T, Box<Error>>, then you can use try! or ? operator to return any kind of error. It will be automatically boxed and converted into the generic Box<Error>.

This works for two reasons:

1) try! and ? don't simply return Err(err) on error case as one might think. They actually return Err(From::from(err)).

2) The standard library has: impl<'a, E: Error + 'a> From<E> for Box<Error + 'a> { ... }

Check out this article, starting from "The From trait": http://blog.burntsushi.net/rust-error-handling/

Re:Announcing Rust 1.13 by stirner on Saturday November 12, 2016 @10:41PM (#12941733)
Another solution I hadn't considered is to simply impl std::convert::From<SomeError> for your custom error type for each SomeError that might be encountered.
Re:Announcing Rust 1.13 by stirner on Friday November 11, 2016 @06:01AM (#12929609)
Awesome, thanks. Does returning boxed errors have a performance impact?
Re:Announcing Rust 1.13 by sklopi on Friday November 11, 2016 @06:05AM (#12929634)
It should only have an impact when errors actually occur, i think.