aboutsummaryrefslogtreecommitdiff
path: root/src/bin.rs
diff options
context:
space:
mode:
authorHristo Venev <hristo@venev.name>2019-03-18 12:37:27 +0200
committerHristo Venev <hristo@venev.name>2019-03-18 12:37:27 +0200
commit761a87cc6e64990b9dd0e235047e1d1e7c7d6971 (patch)
tree920eac8fe6cfc12890cac0f19c9a016ed2b7913b /src/bin.rs
parentac554b8129d2c43d87a5a0abca6bd097d870fe6d (diff)
Lint
Diffstat (limited to 'src/bin.rs')
-rw-r--r--src/bin.rs28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/bin.rs b/src/bin.rs
index 2df3856..99ff766 100644
--- a/src/bin.rs
+++ b/src/bin.rs
@@ -21,30 +21,22 @@ pub fn u64_to_be(v: u64) -> [u8; 8] {
}
pub fn u64_from_be(v: [u8; 8]) -> u64 {
- (u64::from(v[0]) << 56) |
- (u64::from(v[1]) << 48) |
- (u64::from(v[2]) << 40) |
- (u64::from(v[3]) << 32) |
- (u64::from(v[4]) << 24) |
- (u64::from(v[5]) << 16) |
- (u64::from(v[6]) << 8) |
- u64::from(v[7])
+ (u64::from(v[0]) << 56)
+ | (u64::from(v[1]) << 48)
+ | (u64::from(v[2]) << 40)
+ | (u64::from(v[3]) << 32)
+ | (u64::from(v[4]) << 24)
+ | (u64::from(v[5]) << 16)
+ | (u64::from(v[6]) << 8)
+ | u64::from(v[7])
}
pub fn u32_to_be(v: u32) -> [u8; 4] {
- [
- (v >> 24) as u8,
- (v >> 16) as u8,
- (v >> 8) as u8,
- v as u8,
- ]
+ [(v >> 24) as u8, (v >> 16) as u8, (v >> 8) as u8, v as u8]
}
pub fn u32_from_be(v: [u8; 4]) -> u32 {
- (u32::from(v[0]) << 24) |
- (u32::from(v[1]) << 16) |
- (u32::from(v[2]) << 8) |
- u32::from(v[3])
+ (u32::from(v[0]) << 24) | (u32::from(v[1]) << 16) | (u32::from(v[2]) << 8) | u32::from(v[3])
}
pub fn u16_to_be(v: u16) -> [u8; 2] {