Skip to content

Commit 9dfb95b

Browse files
committed
Rollup merge of #53636 - frewsxcv:frewsxcv-nth, r=rkruppe
Prefer `.nth(n)` over `.skip(n).next()`. Found by clippy.
2 parents a37b69d + 9e0ff24 commit 9dfb95b

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

src/libcore/fmt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ impl<'a> Formatter<'a> {
12621262
// If our string is longer that the precision, then we must have
12631263
// truncation. However other flags like `fill`, `width` and `align`
12641264
// must act as always.
1265-
if let Some((i, _)) = s.char_indices().skip(max).next() {
1265+
if let Some((i, _)) = s.char_indices().nth(max) {
12661266
// LLVM here can't prove that `..i` won't panic `&s[..i]`, but
12671267
// we know that it can't panic. Use `get` + `unwrap_or` to avoid
12681268
// `unsafe` and otherwise don't emit any panic-related code

src/librustc_metadata/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
11111111
let trait_ref = tcx.impl_trait_ref(def_id);
11121112
let parent = if let Some(trait_ref) = trait_ref {
11131113
let trait_def = tcx.trait_def(trait_ref.def_id);
1114-
trait_def.ancestors(tcx, def_id).skip(1).next().and_then(|node| {
1114+
trait_def.ancestors(tcx, def_id).nth(1).and_then(|node| {
11151115
match node {
11161116
specialization_graph::Node::Impl(parent) => Some(parent),
11171117
_ => None,

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ fn check_specialization_validity<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
14341434
hir::ImplItemKind::Type(_) => ty::AssociatedKind::Type
14351435
};
14361436

1437-
let parent = ancestors.defs(tcx, trait_item.ident, kind, trait_def.def_id).skip(1).next()
1437+
let parent = ancestors.defs(tcx, trait_item.ident, kind, trait_def.def_id).nth(1)
14381438
.map(|node_item| node_item.map(|parent| parent.defaultness));
14391439

14401440
if let Some(parent) = parent {

src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use proc_macro::*;
1919

2020
#[proc_macro_attribute]
2121
pub fn attr_tru(_attr: TokenStream, item: TokenStream) -> TokenStream {
22-
let name = item.into_iter().skip(1).next().unwrap();
22+
let name = item.into_iter().nth(1).unwrap();
2323
quote!(fn $name() -> bool { true })
2424
}
2525

src/test/run-pass/command-before-exec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use std::sync::Arc;
2424
use std::sync::atomic::{AtomicUsize, Ordering};
2525

2626
fn main() {
27-
if let Some(arg) = env::args().skip(1).next() {
27+
if let Some(arg) = env::args().nth(1) {
2828
match &arg[..] {
2929
"test1" => println!("hello2"),
3030
"test2" => assert_eq!(env::var("FOO").unwrap(), "BAR"),

0 commit comments

Comments
 (0)