Moved the conversion into the function.

This commit is contained in:
Jeff Baskin 2022-07-23 21:42:30 -04:00
parent 59361c0a87
commit a58dd43a2b

View File

@ -41,8 +41,8 @@ impl Generic {
}
}
fn add_source(&mut self, source: MTTError) {
self.source = Some(Arc::new(source));
fn add_source<E: Into<MTTError>>(&mut self, source: E) {
self.source = Some(Arc::new(source.into()));
}
}
@ -94,7 +94,7 @@ mod generics {
let cld_detail = "child error";
let par_err = Generic::new(par_detail);
let mut cld_err = Generic::new(cld_detail);
cld_err.add_source(par_err.into());
cld_err.add_source(par_err);
assert!(
cld_err.source().unwrap().to_string() == par_detail,
"/n/nGot: {}\nWant: {}\n\n",