Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ErrorKind Clone #563

Closed
BR03D opened this issue Jul 23, 2022 · 6 comments
Closed

ErrorKind Clone #563

BR03D opened this issue Jul 23, 2022 · 6 comments

Comments

@BR03D
Copy link

BR03D commented Jul 23, 2022

Is there a reason for ErrorKind not implementing Clone? If not, can we make that happen?

@BR03D
Copy link
Author

BR03D commented Jul 23, 2022

The new DecodeError does not implement it either - why?

@VictorKoenders
Copy link
Contributor

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

@BR03D
Copy link
Author

BR03D commented Jul 23, 2022

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.

@VictorKoenders
Copy link
Contributor

You could wrap the DecodeError in an Arc or Rc, that would give you a Clone implementation

@BR03D
Copy link
Author

BR03D commented Jul 23, 2022

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.

@VictorKoenders
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants