2 Checks for usage of `libc::strlen` on a `CString` or `CStr` value,
3 and suggest calling `as_bytes().len()` or `to_bytes().len()` respectively instead.
6 This avoids calling an unsafe `libc` function.
7 Currently, it also avoids calculating the length.
11 use std::ffi::CString;
12 let cstring = CString::new("foo").expect("CString::new failed");
13 let len = unsafe { libc::strlen(cstring.as_ptr()) };
17 use std::ffi::CString;
18 let cstring = CString::new("foo").expect("CString::new failed");
19 let len = cstring.as_bytes().len();