Open clouds56 opened 2 years ago
Thanks for fast reply! Error type that not cloneable usually has a cloneable ErrorKind like std::io::ErrorKind. The error here could derive clone, so why not?
But how do you concretely want to use the clonability of those things?
I'm using thiserror wrap errors, if r2d2::Error supports clone, I could use #[from]
.
The error would be cloned and send to log thread so it must derive Clone
#[derive(Debug, Clone, thiserror::Error)]
pub enum Error {
#[error("pool error: {0}")]
PoolArc(Arc<r2d2::Error>),
#[error("pool error: {0}")]
Pool(#[from] r2d2::Error),
}
You could see lots of error's (if not most) in std derives clone even they could have a large Vec<u8>
, FromVecWithNulError, FromUtf8Error, fmt::Error, VarError, SystemTimeError, I think the policy is just derive Clone
whenever possible.
The std::io::Error is an exception since it couldn't.
What's the rationale for this? Error types are generally not cloneable.