Skip to content

Commit 8c4b1dd

Browse files
committed
Clean up byteorder use
1 parent e8d1790 commit 8c4b1dd

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern crate hex;
1717
extern crate md5;
1818
extern crate memchr;
1919

20-
use byteorder::{WriteBytesExt, BigEndian};
20+
use byteorder::{BigEndian, ByteOrder};
2121
use std::io;
2222

2323
pub mod authentication;
@@ -46,7 +46,7 @@ fn write_nullable<F, E>(serializer: F, buf: &mut Vec<u8>) -> Result<(), E>
4646
IsNull::No => try!(i32::from_usize(buf.len() - base - 4)),
4747
IsNull::Yes => -1,
4848
};
49-
(&mut buf[base..base + 4]).write_i32::<BigEndian>(size).unwrap();
49+
BigEndian::write_i32(&mut buf[base..], size);
5050

5151
Ok(())
5252
}

src/message/frontend.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Frontend message serialization.
22
#![allow(missing_docs)]
33

4-
use byteorder::{WriteBytesExt, BigEndian};
4+
use byteorder::{WriteBytesExt, BigEndian, ByteOrder};
55
use std::error::Error;
66
use std::io;
77
use std::marker;
@@ -122,7 +122,7 @@ fn write_body<F, E>(buf: &mut Vec<u8>, f: F) -> Result<(), E>
122122
try!(f(buf));
123123

124124
let size = try!(i32::from_usize(buf.len() - base));
125-
(&mut buf[base..base + 4]).write_i32::<BigEndian>(size).unwrap();
125+
BigEndian::write_i32(&mut buf[base..], size);
126126
Ok(())
127127
}
128128

@@ -188,7 +188,7 @@ fn write_counted<I, T, F, E>(items: I, mut serializer: F, buf: &mut Vec<u8>) ->
188188
count += 1;
189189
}
190190
let count = try!(i16::from_usize(count));
191-
(&mut buf[base..base + 2]).write_i16::<BigEndian>(count).unwrap();
191+
BigEndian::write_i16(&mut buf[base..], count);
192192

193193
Ok(())
194194
}

0 commit comments

Comments
 (0)