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! {
3758
3758
/// Checks for calls to `CString::new` and `CStr::from_bytes_with_nul` with byte string literals as arguments.
3759
3759
///
3760
3760
/// ### 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.
3762
3763
///
3763
3764
/// ### Example
3764
3765
/// ```no_run
3765
3766
/// # use std::ffi::CStr;
3766
- /// # fn needs_cstr(_: &str ) {}
3767
+ /// # fn needs_cstr(_: &CStr ) {}
3767
3768
/// needs_cstr(CStr::from_bytes_with_nul(b":)").unwrap());
3768
3769
/// ```
3769
3770
/// Use instead:
3770
3771
/// ```no_run
3771
3772
/// # use std::ffi::CStr;
3772
- /// # fn needs_cstr(_: &str ) {}
3773
+ /// # fn needs_cstr(_: &CStr ) {}
3773
3774
/// needs_cstr(c":)");
3774
3775
/// ```
3775
3776
#[ clippy:: version = "1.76.0" ]
You can’t perform that action at this time.
0 commit comments