*/: 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:
Thomas Eizinger
2021-08-03 23:55:36 +10:00
committed by GitHub
parent e1f1af899b
commit 9d6562229f
7 changed files with 29 additions and 21 deletions

View File

@ -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()