These are chat archives for rust-lang/rust

28th
Oct 2017
David Harvey-Macaulay
@alteous
Oct 28 2017 12:54
How do I install and use rustc nightly version 1.20 using rustup?
Denis Lisov
@tanriol
Oct 28 2017 12:56
There's no single "nightly 1.20" version. I'd pick some date when 1.20 was in nightly and rustup install nightly-2017-mm-dd
David Harvey-Macaulay
@alteous
Oct 28 2017 13:00
@tanriol Thanks, this worked. For future reference: I browsed the releases page and installed nightly-2017-07-19.
Of course, the nightly version is always one major version ahead of the latest stable version.
Moggers
@Moggers
Oct 28 2017 21:42
how can I use the ? operator with my own error types?
Do I need to write a From<T> implementation for each of the error types I want to use a ? on?
Max Frai
@max-frai
Oct 28 2017 21:42
Look at error_chain
It has nice macro which auto inherits everything you need
Moggers
@Moggers
Oct 28 2017 21:43
hmm
Jonas Platte
@jplatte
Oct 28 2017 21:46
@Moggers If by own error types you mean different values for the E parameter / Err variant of Result, then yes, you need impl From<OtherError> for MyError
If you mean using ? in a function that returns your own type that encapsulates errors in some way, that is only possible on Nightly right now, by implementing the Try trait for that type: https://doc.rust-lang.org/std/ops/trait.Try.html
Moggers
@Moggers
Oct 28 2017 21:48
no, you were right the first time
just some less boilerplatey way of wrapping foreign errors inside my own, with my own provided context to where the error was triggered
I think error_chain can give me what i'm looking for
Jonas Platte
@jplatte
Oct 28 2017 21:49
Yeah
There is one other popular one too
Moggers
@Moggers
Oct 28 2017 21:49
I'm kind of scared of using macros excessively
probably not warranted
but I'm scared of confusing the compiler with metaprogramming
so when I mess something up it spits out gibberish at me
Jonas Platte
@jplatte
Oct 28 2017 21:51
(just looked it up, quick-error is the other one)
Moggers
@Moggers
Oct 28 2017 21:51
oh wow that looks cool too
Moggers
@Moggers
Oct 28 2017 21:57
oh wow this is GREAT