match successor_count {
0 => Ok(()),
- 1 => write!(fmt, " -> {:?}", self.successors().nth(0).unwrap()),
+ 1 => write!(fmt, " -> {:?}", self.successors().next().unwrap()),
_ => {
write!(fmt, " -> [")?;
let mut dtor_did = None;
let ty = self.type_of(adt_did);
self.for_each_relevant_impl(drop_trait, ty, |impl_did| {
- if let Some(item) = self.associated_items(impl_did).in_definition_order().nth(0) {
+ if let Some(item) = self.associated_items(impl_did).in_definition_order().next() {
if validate(self, impl_did).is_ok() {
dtor_did = Some(item.def_id);
}
};
let first_succ = {
- if let Some(&first_succ) = terminator.successors().nth(0) {
+ if let Some(&first_succ) = terminator.successors().next() {
if terminator.successors().all(|s| *s == first_succ) {
let count = terminator.successors().count();
self.pred_count[first_succ] -= (count - 1) as u32;
debug!("destructor_call_block({:?}, {:?})", self, succ);
let tcx = self.tcx();
let drop_trait = tcx.lang_items().drop_trait().unwrap();
- let drop_fn = tcx.associated_items(drop_trait).in_definition_order().nth(0).unwrap();
+ let drop_fn = tcx.associated_items(drop_trait).in_definition_order().next().unwrap();
let ty = self.place_ty(self.place);
let substs = tcx.mk_substs_trait(ty, &[]);
PatKind::Leaf { subpatterns }
}
}
- ty::Ref(..) => PatKind::Deref { subpattern: subpatterns.nth(0).unwrap() },
+ ty::Ref(..) => PatKind::Deref { subpattern: subpatterns.next().unwrap() },
ty::Slice(_) | ty::Array(..) => bug!("bad slice pattern {:?} {:?}", self, ty),
_ => PatKind::Wild,
},
};
let kind = if es.len() == 1 && !trailing_comma {
// `(e)` is parenthesized `e`.
- ExprKind::Paren(es.into_iter().nth(0).unwrap())
+ ExprKind::Paren(es.into_iter().next().unwrap())
} else {
// `(e,)` is a tuple with only one field, `e`.
ExprKind::Tup(es)
// Here, `(pat,)` is a tuple pattern.
// For backward compatibility, `(..)` is a tuple pattern as well.
Ok(if fields.len() == 1 && !(trailing_comma || fields[0].is_rest()) {
- PatKind::Paren(fields.into_iter().nth(0).unwrap())
+ PatKind::Paren(fields.into_iter().next().unwrap())
} else {
PatKind::Tuple(fields)
})
})?;
if ts.len() == 1 && !trailing {
- let ty = ts.into_iter().nth(0).unwrap().into_inner();
+ let ty = ts.into_iter().next().unwrap().into_inner();
let maybe_bounds = allow_plus == AllowPlus::Yes && self.token.is_like_plus();
match ty.kind {
// `(TY_BOUND_NOPAREN) + BOUND + ...`.
/// if no character could be found or if an error occurred while retrieving the code snippet.
pub fn span_extend_to_prev_char(&self, sp: Span, c: char) -> Span {
if let Ok(prev_source) = self.span_to_prev_source(sp) {
- let prev_source = prev_source.rsplit(c).nth(0).unwrap_or("").trim_start();
+ let prev_source = prev_source.rsplit(c).next().unwrap_or("").trim_start();
if !prev_source.is_empty() && !prev_source.contains('\n') {
return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32));
}
for ws in &[" ", "\t", "\n"] {
let pat = pat.to_owned() + ws;
if let Ok(prev_source) = self.span_to_prev_source(sp) {
- let prev_source = prev_source.rsplit(&pat).nth(0).unwrap_or("").trim_start();
+ let prev_source = prev_source.rsplit(&pat).next().unwrap_or("").trim_start();
if !prev_source.is_empty() && (!prev_source.contains('\n') || accept_newlines) {
return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32));
}
pub fn span_until_char(&self, sp: Span, c: char) -> Span {
match self.span_to_snippet(sp) {
Ok(snippet) => {
- let snippet = snippet.split(c).nth(0).unwrap_or("").trim_end();
+ let snippet = snippet.split(c).next().unwrap_or("").trim_end();
if !snippet.is_empty() && !snippet.contains('\n') {
sp.with_hi(BytePos(sp.lo().0 + snippet.len() as u32))
} else {
// The `Future` trait has only one associted item, `Output`,
// so check that this is what we see.
let output_assoc_item =
- self.tcx.associated_items(future_trait).in_definition_order().nth(0).unwrap().def_id;
+ self.tcx.associated_items(future_trait).in_definition_order().next().unwrap().def_id;
if output_assoc_item != predicate.projection_ty.item_def_id {
span_bug!(
cause_span,
.tcx
.associated_items(future_trait)
.in_definition_order()
- .nth(0)
+ .next()
.unwrap()
.def_id;
let predicate =
eprintln!("Must provide path to write unicode tables to");
eprintln!(
"e.g. {} src/libcore/unicode/unicode_data.rs",
- std::env::args().nth(0).unwrap_or_default()
+ std::env::args().next().unwrap_or_default()
);
std::process::exit(1);
});