Skip to content

Commit c6a647a

Browse files
committed
Replace map(|x| *x) with cloned().
This partially resolves #22243.
1 parent cf636c2 commit c6a647a

File tree

19 files changed

+25
-25
lines changed

19 files changed

+25
-25
lines changed

src/libcollections/bit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ mod tests {
22822282
#[test]
22832283
fn test_from_bools() {
22842284
let bools = vec![true, false, true, true];
2285-
let bitv: Bitv = bools.iter().map(|n| *n).collect();
2285+
let bitv: Bitv = bools.iter().cloned().collect();
22862286
assert_eq!(format!("{:?}", bitv), "1011");
22872287
}
22882288

@@ -2295,12 +2295,12 @@ mod tests {
22952295
#[test]
22962296
fn test_bitv_iterator() {
22972297
let bools = vec![true, false, true, true];
2298-
let bitv: Bitv = bools.iter().map(|n| *n).collect();
2298+
let bitv: Bitv = bools.iter().cloned().collect();
22992299

23002300
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools);
23012301

23022302
let long: Vec<_> = (0i32..10000).map(|i| i % 2 == 0).collect();
2303-
let bitv: Bitv = long.iter().map(|n| *n).collect();
2303+
let bitv: Bitv = long.iter().cloned().collect();
23042304
assert_eq!(bitv.iter().collect::<Vec<bool>>(), long)
23052305
}
23062306

src/libcore/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ pub trait IteratorExt: Iterator + Sized {
325325
///
326326
/// ```
327327
/// let xs = [100, 200, 300];
328-
/// let mut it = xs.iter().map(|x| *x).peekable();
328+
/// let mut it = xs.iter().cloned().peekable();
329329
/// assert_eq!(*it.peek().unwrap(), 100);
330330
/// assert_eq!(it.next().unwrap(), 100);
331331
/// assert_eq!(it.next().unwrap(), 200);

src/libcoretest/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ fn test_random_access_inspect() {
713713
fn test_random_access_map() {
714714
let xs = [1, 2, 3, 4, 5];
715715

716-
let mut it = xs.iter().map(|x| *x);
716+
let mut it = xs.iter().cloned();
717717
assert_eq!(xs.len(), it.indexable());
718718
for (i, elt) in xs.iter().enumerate() {
719719
assert_eq!(Some(*elt), it.idx(i));

src/librustc/metadata/cstore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl CStore {
218218

219219
pub fn find_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId)
220220
-> Option<ast::CrateNum> {
221-
self.extern_mod_crate_map.borrow().get(&emod_id).map(|x| *x)
221+
self.extern_mod_crate_map.borrow().get(&emod_id).cloned()
222222
}
223223
}
224224

src/librustc/middle/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'a> fmt::Debug for Matrix<'a> {
7575
pretty_printed_matrix.iter().map(|row| row[col].len()).max().unwrap_or(0)
7676
}).collect();
7777

78-
let total_width = column_widths.iter().map(|n| *n).sum() + column_count * 3 + 1;
78+
let total_width = column_widths.iter().cloned().sum() + column_count * 3 + 1;
7979
let br = repeat('+').take(total_width).collect::<String>();
8080
try!(write!(f, "{}\n", br));
8181
for row in pretty_printed_matrix {

src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ pub fn lit_to_const(lit: &ast::Lit) -> const_val {
600600
match lit.node {
601601
ast::LitStr(ref s, _) => const_str((*s).clone()),
602602
ast::LitBinary(ref data) => {
603-
const_binary(Rc::new(data.iter().map(|x| *x).collect()))
603+
const_binary(Rc::new(data.iter().cloned().collect()))
604604
}
605605
ast::LitByte(n) => const_uint(n as u64),
606606
ast::LitChar(n) => const_uint(n as u64),

src/librustc/middle/dependency_format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn calculate_type(sess: &session::Session,
158158

159159
// Collect what we've got so far in the return vector.
160160
let mut ret = (1..sess.cstore.next_crate_num()).map(|i| {
161-
match formats.get(&i).map(|v| *v) {
161+
match formats.get(&i).cloned() {
162162
v @ Some(cstore::RequireDynamic) => v,
163163
_ => None,
164164
}

src/librustc/middle/lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a, 'v> Visitor<'v> for LanguageItemCollector<'a> {
149149
fn visit_item(&mut self, item: &ast::Item) {
150150
match extract(&item.attrs) {
151151
Some(value) => {
152-
let item_index = self.item_refs.get(&value[]).map(|x| *x);
152+
let item_index = self.item_refs.get(&value[]).cloned();
153153

154154
match item_index {
155155
Some(item_index) => {

src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl RegionMaps {
407407

408408
pub fn opt_encl_scope(&self, id: CodeExtent) -> Option<CodeExtent> {
409409
//! Returns the narrowest scope that encloses `id`, if any.
410-
self.scope_map.borrow().get(&id).map(|x| *x)
410+
self.scope_map.borrow().get(&id).cloned()
411411
}
412412

413413
#[allow(dead_code)] // used in middle::cfg

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4944,7 +4944,7 @@ pub fn note_and_explain_type_err(cx: &ctxt, err: &type_err) {
49444944
}
49454945

49464946
pub fn provided_source(cx: &ctxt, id: ast::DefId) -> Option<ast::DefId> {
4947-
cx.provided_method_sources.borrow().get(&id).map(|x| *x)
4947+
cx.provided_method_sources.borrow().get(&id).cloned()
49484948
}
49494949

49504950
pub fn provided_trait_methods<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)

0 commit comments

Comments
 (0)