Why can't I return an &str value generated from a String?
I'm having some trouble trying to grasp why I can't return an &str value generated from a String (goodness, when will as_str be ready?) and I'm doing something wrong. I get this idea because nothing that I do makes the value live long enough to use. I'm trying to implement error::Error for a custom struct: impl error::Error for LexicalError { fn description(&self) -> &str { let s = format!("{}", self); // s doesn't live long enough to do this, I've tried // cloning s and using that, but still the clone doesn't // live long enough. s.trim() } fn cause(&self) -> Option<&error::Error> { None } }