bincode
bincode copied to clipboard
ErrorKind Clone
Is there a reason for ErrorKind not implementing Clone? If not, can we make that happen?
The new DecodeError does not implement it either - why?
I'm assuming you mean EncodeError
. This enum uses the following types that do not implement Clone
:
We could implement Clone
on DecodeError
but I think it makes sense that both error types implement the same traits
I was specifically referring to DecodeError. My application reads input from a TcpStream and in case of a DecodeError I want to attach that error to the return value (which i would like to be cloneable).
I dont see why both errors need to implement the same traits - imo if something can be Clone it should be.
You could wrap the DecodeError
in an Arc
or Rc
, that would give you a Clone
implementation
That is a good suggestion. I will implement it like this for now.
Still, if there is no reason for why it wouldnt be Clone
, it should probably implement it.
Turns out DecodeError
should import std::io::Error
, so I've added that in this PR.
If you want the two types mentioned above to implement Clone
, please open up an issue on the rust issue tracker. We are open to implement any trait that core::cell::BorrowError
and std::io::Error
implement.
Feel free to re-open this issue when the traits implements change in a stable version of rust.