mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Adressed all comments
This commit is contained in:
@ -61,6 +61,7 @@ where
|
||||
bincode::deserialize(slice).map_err(|_| "Failed to deserialize function input")
|
||||
}
|
||||
|
||||
/// This function split a u128 in two u64 encoding them as le bytes
|
||||
pub fn from_u128(i: u128) -> (u64, u64) {
|
||||
let i = i.to_le_bytes();
|
||||
(
|
||||
@ -69,14 +70,17 @@ pub fn from_u128(i: u128) -> (u64, u64) {
|
||||
)
|
||||
}
|
||||
|
||||
/// This function merge two u64 encoded as le in one u128
|
||||
pub fn to_u128(a: u64, b: u64) -> u128 {
|
||||
let a = a.to_le_bytes();
|
||||
let b = b.to_le_bytes();
|
||||
u128::from_le_bytes([a, b].concat().try_into().unwrap())
|
||||
}
|
||||
|
||||
/// This function encode a u64 into a i64 using le bytes
|
||||
pub fn to_i64(i: u64) -> i64 { i64::from_le_bytes(i.to_le_bytes()) }
|
||||
|
||||
/// This function decode a i64 into a u64 using le bytes
|
||||
pub fn from_i64(i: i64) -> u64 { u64::from_le_bytes(i.to_le_bytes()) }
|
||||
|
||||
static mut VEC: Vec<u8> = vec![];
|
||||
|
Reference in New Issue
Block a user