]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/manual_split_once.rs
Ignore associated items in trait *implementations* when considering type complexity
[rust.git] / tests / ui / manual_split_once.rs
index e6093b63fe8d428e348760d6a496a3ae4d433090..80e02952dbd07f8adf537d03f093a9eb580fb92e 100644 (file)
@@ -2,7 +2,7 @@
 
 #![feature(custom_inner_attributes)]
 #![warn(clippy::manual_split_once)]
-#![allow(clippy::iter_skip_next, clippy::iter_nth_zero)]
+#![allow(clippy::iter_skip_next, clippy::iter_nth_zero, clippy::needless_splitn)]
 
 extern crate itertools;
 
@@ -36,6 +36,12 @@ fn _f(s: &str) -> Option<&str> {
 
     // Don't lint, slices don't have `split_once`
     let _ = [0, 1, 2].splitn(2, |&x| x == 1).nth(1).unwrap();
+
+    // `rsplitn` gives the results in the reverse order of `rsplit_once`
+    let _ = "key=value".rsplitn(2, '=').next().unwrap();
+    let _ = "key=value".rsplitn(2, '=').nth(1).unwrap();
+    let _ = "key=value".rsplitn(2, '=').nth(0);
+    let (_, _) = "key=value".rsplitn(2, '=').next_tuple().unwrap();
 }
 
 fn _msrv_1_51() {