mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-15 11:01:21 +00:00
*/: Replace Into
with From
(#2169)
Unless restricted by orphan rules, implementing `From` is superior because it implies `Into` but leaves the choice to the user, which one to use. Especially for errors, `From` is convenient because that is what `?` builds on. Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@ -391,9 +391,9 @@ impl From<io::Error> for ProtocolError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<io::Error> for ProtocolError {
|
||||
fn into(self) -> io::Error {
|
||||
if let ProtocolError::IoError(e) = self {
|
||||
impl From<ProtocolError> for io::Error {
|
||||
fn from(err: ProtocolError) -> Self {
|
||||
if let ProtocolError::IoError(e) = err {
|
||||
return e
|
||||
}
|
||||
io::ErrorKind::InvalidData.into()
|
||||
|
Reference in New Issue
Block a user