INNER CODE UNIT · Rust

to_le_bytes

TheMaxMur/RS-Key · crates/rsk-bench/src/lib.rs:52

    pub fn to_le_bytes(&self) -> [u8; SUMMARY_LEN] {
        let mut b = [0u8; SUMMARY_LEN];
        b[0..4].copy_from_slice(&self.n.to_le_bytes());
        b[4..8].copy_from_slice(&self.cold.to_le_bytes());
        b[8..12].copy_from_slice(&self.min.to_le_bytes());
        b[12..16].copy_from_slice(&self.median.to_le_bytes());
        b[16..20].copy_from_slice(&self.mad.to_le_bytes());
        b
    }

    /// Inverse of [`Summary::to_le_bytes`].
    pub fn from_le_bytes(b: &[u8; SUMMARY_LEN]) -> Self {
        let u = |i: usize| u32::from_le_bytes([b[i], b[i + 1], b[i + 2], b[i + 3]]);
        Summary {
            n: u(0),
            cold: u(4),
            min: u(8),
            median: u(12),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…