diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml index c752152432..44e42356d8 100644 --- a/src/core/Cargo.toml +++ b/src/core/Cargo.toml @@ -25,8 +25,7 @@ parallel = ["rayon"] #cbindgen = "~0.6.7" [dependencies] -#byteorder = "1.3.2" -byteorder = { git = "https://github.com/luizirber/byteorder", branch="write_u32_from" } +byteorder = "1.3.2" cfg-if = "0.1.10" failure = "0.1.6" failure_derive = "0.1.6" diff --git a/src/core/src/sketch/nodegraph.rs b/src/core/src/sketch/nodegraph.rs index 5856db1598..f7f685c9d5 100644 --- a/src/core/src/sketch/nodegraph.rs +++ b/src/core/src/sketch/nodegraph.rs @@ -1,6 +1,7 @@ use std::fs::File; use std::io; use std::path::Path; +use std::slice; use byteorder::{BigEndian, ByteOrder, LittleEndian, ReadBytesExt, WriteBytesExt}; use failure::Error; @@ -175,8 +176,20 @@ impl Nodegraph { let byte_size = tablesize / 8 + 1; let (div, rem) = (byte_size / 4, byte_size % 4); + // Once this issue and PR are solved, this is a one liner: // https://github.com/BurntSushi/byteorder/issues/155 - wtr.write_u32_from::(&count.as_slice()[..div])?; + // https://github.com/BurntSushi/byteorder/pull/166 + //wtr.write_u32_from::(&count.as_slice()[..div])?; + let slice = &count.as_slice()[..div]; + let buf = unsafe { + use std::mem::size_of; + + let len = size_of::() * slice.len(); + slice::from_raw_parts(slice.as_ptr() as *const u8, len) + }; + wtr.write_all(&buf)?; + // Replace when byteorder PR is released + if rem != 0 { let mut cursor = [0u8; 4]; LittleEndian::write_u32(&mut cursor, count.as_slice()[div]);