소스 검색

Merge pull request #129 from ids1024/cstr

Simplify cstr_from_bytes_with_nul_unchecked()
Jeremy Soller 7 년 전
부모
커밋
aead6d8fd0
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/platform/src/lib.rs

+ 1 - 1
src/platform/src/lib.rs

@@ -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