File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -3758,18 +3758,19 @@ declare_clippy_lint! {
37583758 /// Checks for calls to `CString::new` and `CStr::from_bytes_with_nul` with byte string literals as arguments.
37593759 ///
37603760 /// ### Why is this bad?
3761- /// This can be written more concisely using `c"str"` literals.
3761+ /// This can be written more concisely using `c"str"` literals and is also less error-prone,
3762+ /// because the compiler checks for interior nul bytes.
37623763 ///
37633764 /// ### Example
37643765 /// ```no_run
37653766 /// # use std::ffi::CStr;
3766- /// # fn needs_cstr(_: &str ) {}
3767+ /// # fn needs_cstr(_: &CStr ) {}
37673768 /// needs_cstr(CStr::from_bytes_with_nul(b":)").unwrap());
37683769 /// ```
37693770 /// Use instead:
37703771 /// ```no_run
37713772 /// # use std::ffi::CStr;
3772- /// # fn needs_cstr(_: &str ) {}
3773+ /// # fn needs_cstr(_: &CStr ) {}
37733774 /// needs_cstr(c":)");
37743775 /// ```
37753776 #[ clippy:: version = "1.76.0" ]
You can’t perform that action at this time.
0 commit comments