Skip to content
Snippets Groups Projects
Unverified Commit 5bcf1d42 authored by Ian Douglas Scott's avatar Ian Douglas Scott
Browse files

Simplify cstr_from_bytes_with_nul_unchecked()

The original implementation is modified from the `Cstr` method, but the
complexity there exists because it is trying to convert to the DST `Cstr`.
parent 3311a700
No related branches found
No related tags found
1 merge request!129Simplify cstr_from_bytes_with_nul_unchecked()
......@@ -55,7 +55,7 @@ pub unsafe fn c_str_n(s: *const c_char, n: usize) -> &'static [u8] {
}
pub unsafe fn cstr_from_bytes_with_nul_unchecked(bytes: &[u8]) -> *const c_char {
&*(bytes as *const [u8] as *const c_char)
bytes.as_ptr() as *const c_char
}
// NOTE: defined here rather than in string because memcpy() is useful in multiple crates
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment