Skip to content

Commit 6620aa0

Browse files
FoseFxflip1995
andcommitted
update case_sensitive_file_extension_comparisons example
The old example does not work in case the delimiter is not in the name Co-authored-by: flip1995 <[email protected]>
1 parent 05a51e5 commit 6620aa0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clippy_lints/src/case_sensitive_file_extension_comparisons.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ declare_clippy_lint! {
2424
/// Use instead:
2525
/// ```rust
2626
/// fn is_rust_file(filename: &str) -> bool {
27-
/// filename.rsplit('.').next().map(|ext| ext.eq_ignore_ascii_case("rs")) == Some(true)
27+
/// let filename = std::path::Path::new(filename);
28+
/// filename.extension()
29+
/// .map(|ext| ext.eq_ignore_ascii_case("rs"))
30+
/// .unwrap_or(false)
2831
/// }
2932
/// ```
3033
#[clippy::version = "1.51.0"]

0 commit comments

Comments
 (0)