Per qualche motivo, il compilatore di Rust si lamenta che lo Result
non implementa unwrap
, anche se il tipo di errore I fornito implementa Debug. Il codice che genera errori è fornito di seguito.Il tipo di risultato non implementa il metodo nell'ambito denominato `unwrap`
use std::fmt::{Display, Debug};
use std::error::Error;
trait MyError: Error + Display + Debug {}
type MyResult<T> = Result<T, MyError>;
trait Foo: Clone {}
trait MyTrait {
fn my_function<T: Foo>(&self) -> MyResult<T>;
fn unwrap_function<T: Foo>(&self) -> T {
self.my_function().unwrap()
}
}