Merge pull request #125 from Dushistov/fix-from-for-close-code

Change Into to From for CloseCode to u16 conversation
pull/126/head
Alexey Galakhov 5 years ago committed by GitHub
commit 3a24ca3f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/protocol/frame/coding.rs

@ -202,9 +202,9 @@ impl fmt::Display for CloseCode {
} }
} }
impl<'t> Into<u16> for &'t CloseCode { impl From<CloseCode> for u16 {
fn into(self) -> u16 { fn from(code: CloseCode) -> u16 {
match *self { match code {
Normal => 1000, Normal => 1000,
Away => 1001, Away => 1001,
Protocol => 1002, Protocol => 1002,
@ -227,9 +227,9 @@ impl<'t> Into<u16> for &'t CloseCode {
} }
} }
impl Into<u16> for CloseCode { impl<'t> From<&'t CloseCode> for u16 {
fn into(self) -> u16 { fn from(code: &'t CloseCode) -> u16 {
(&self).into() (*code).into()
} }
} }
@ -287,5 +287,6 @@ mod tests {
let text = CloseCode::Away; let text = CloseCode::Away;
let byte: u16 = text.into(); let byte: u16 = text.into();
assert_eq!(byte, 1001u16); assert_eq!(byte, 1001u16);
assert_eq!(u16::from(text), 1001u16);
} }
} }

Loading…
Cancel
Save