Skip to content

Instantly share code, notes, and snippets.

@jnicklas
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnicklas/21f9c1230e64150827aa to your computer and use it in GitHub Desktop.
Save jnicklas/21f9c1230e64150827aa to your computer and use it in GitHub Desktop.
standard_error.rs:14:28: 14:35 error: cannot infer an appropriate lifetime for pattern due to conflicting requirements
standard_error.rs:14 StandardErrorWrapped(ref err) => err.description()
^~~~~~~
standard_error.rs:14:40: 14:43 note: first, the lifetime cannot outlive the expression at 14:39...
standard_error.rs:14 StandardErrorWrapped(ref err) => err.description()
^~~
standard_error.rs:14:40: 14:43 note: ...so that pointer is not dereferenced outside its lifetime
standard_error.rs:14 StandardErrorWrapped(ref err) => err.description()
^~~
standard_error.rs:12:5: 15:6 note: but, the lifetime must be valid for the match at 12:4...
standard_error.rs:12 match *self {
standard_error.rs:13 StandardErrorActual { description: description } => description,
standard_error.rs:14 StandardErrorWrapped(ref err) => err.description()
standard_error.rs:15 }
standard_error.rs:14:28: 14:35 note: ...so that variable is valid at time of its declaration
standard_error.rs:14 StandardErrorWrapped(ref err) => err.description()
^~~~~~~
error: aborting due to previous error
#![feature(struct_variant)]
use std::error::Error;
enum StandardError {
StandardErrorActual { description: &'static str },
StandardErrorWrapped(Box<Error+Send+'static>)
}
impl Error for StandardError {
fn description(&self) -> &'static str {
match *self {
StandardErrorActual { description: description } => description,
StandardErrorWrapped(ref err) => err.description()
}
}
fn detail(&self) -> Option<String> {
None
}
fn cause(&self) -> Option<&Error> {
None
}
}
fn main() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment