mirror of
https://github.com/TECHNOFAB11/aerosol.git
synced 2025-12-12 08:00:08 +01:00
Allow anyhow::Error as Error type
This commit is contained in:
parent
489b5d04d8
commit
079fbb4654
4 changed files with 12 additions and 15 deletions
|
|
@ -1,7 +1,4 @@
|
|||
use std::{
|
||||
any::{type_name, Any},
|
||||
error::Error,
|
||||
};
|
||||
use std::any::{type_name, Any};
|
||||
|
||||
/// Bound on the types that can be used as an aerosol resource.
|
||||
pub trait Resource: Any + Send + Sync + Clone {}
|
||||
|
|
@ -15,10 +12,10 @@ pub(crate) fn unwrap_resource<T: Resource>(opt: Option<T>) -> T {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn unwrap_constructed<T: Resource, U>(res: Result<U, impl Error>) -> U {
|
||||
pub(crate) fn unwrap_constructed<T: Resource, U>(res: Result<U, impl Into<anyhow::Error>>) -> U {
|
||||
match res {
|
||||
Ok(x) => x,
|
||||
Err(e) => panic!("Failed to construct `{}`: {}", type_name::<T>(), e),
|
||||
Err(e) => panic!("Failed to construct `{}`: {}", type_name::<T>(), e.into()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue