about summary refs log tree commit diff
path: root/src/docs/strlen_on_c_strings.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/docs/strlen_on_c_strings.txt')
-rw-r--r--src/docs/strlen_on_c_strings.txt20
1 files changed, 0 insertions, 20 deletions
diff --git a/src/docs/strlen_on_c_strings.txt b/src/docs/strlen_on_c_strings.txt
deleted file mode 100644
index 0454abf55a2..00000000000
--- a/src/docs/strlen_on_c_strings.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-### What it does
-Checks for usage of `libc::strlen` on a `CString` or `CStr` value,
-and suggest calling `as_bytes().len()` or `to_bytes().len()` respectively instead.
-
-### Why is this bad?
-This avoids calling an unsafe `libc` function.
-Currently, it also avoids calculating the length.
-
-### Example
-```
-use std::ffi::CString;
-let cstring = CString::new("foo").expect("CString::new failed");
-let len = unsafe { libc::strlen(cstring.as_ptr()) };
-```
-Use instead:
-```
-use std::ffi::CString;
-let cstring = CString::new("foo").expect("CString::new failed");
-let len = cstring.as_bytes().len();
-```
\ No newline at end of file