by avinassh · 2y ago · 0 comments
fn alloc_string(s: &str) -> NonNull<u8> {
let boxed_slice = s.as_bytes().to_owned().into_boxed_slice();
NonNull::new(Box::into_raw(boxed_slice) as *mut u8).unwrap()
}
Approximately, if stdlib was taking 1µs, but my code was about 14-15µs for large strings. Profiling also did not help. Anyone have any guesses? Here is the full code: https://github.com/avinassh/string-allochttps://doc.rust-lang.org/nightly/src/alloc/slice.rs.html#16...