InternalError
to be able to hold either a std::env::VarError
or a reqwest::Error
enum Error { InternalError, BackendError(String) }
not really sure how to shove either error into an InternalErrorenum Error { VarError(std::env::VarError), ReqwestError(reqwest::Error), BackendError(String)}
but I'd much prefer if I could have just one InternalError
enum Error { Internal(anyhow::Error), Backend(String) }
Box<dyn Error>
underneath it all)enum Error { Internal(Box<dyn Error>), Backend(String) }
// or
enum Error { Internal(InternalError), Backend(String) }
enum InternalError { Var(std::env::VarError), Reqwest(reqwest::Error) }
impl From<std::env::VarError> for Error {
fn from(e: std::env::VarError) -> Error {
Error::Internal(InternalError::Var(e))
}
}
Box<dyn Error>
anyway, apparently reqwest errors don't implement the trait Cloneget_or_init
to initialize it onceUnsafeCell
. Say InitializeCell
: use std::cell::UnsafeCell;
use std::mem::MaybeUninit;
use std::ops;
pub struct InitializeCell<T> {
inner: UnsafeCell<MaybeUninit<T>>,
}
unsafe impl<T> Sync for InitializeCell<T> {}
impl<T> Initiali...Arc<HashMap<K, V>>
?