






























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 InternalError

enum 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 Clone




















get_or_init to initialize it once





UnsafeCell. 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...
Hacker News • 2020-07-22 20:00:14Z 






Arc<HashMap<K, V>>?
