Skip to content

Commit

Permalink
sorted_map: change From<Iterator<I>> to FromIterator<I>
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Dec 10, 2018
1 parent 286dc37 commit 875ce5f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/librustc_data_structures/sorted_map.rs
Expand Up @@ -10,7 +10,7 @@

use std::borrow::Borrow;
use std::cmp::Ordering;
use std::convert::From;
use std::iter::FromIterator;
use std::mem;
use std::ops::{RangeBounds, Bound, Index, IndexMut};

Expand Down Expand Up @@ -272,9 +272,9 @@ impl<K: Ord, V, Q: Borrow<K>> IndexMut<Q> for SortedMap<K, V> {
}
}

impl<K: Ord, V, I: Iterator<Item=(K, V)>> From<I> for SortedMap<K, V> {
fn from(data: I) -> Self {
let mut data: Vec<(K, V)> = data.collect();
impl<K: Ord, V> FromIterator<(K, V)> for SortedMap<K, V> {
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
let mut data: Vec<(K, V)> = iter.into_iter().collect();
data.sort_unstable_by(|&(ref k1, _), &(ref k2, _)| k1.cmp(k2));
data.dedup_by(|&mut (ref k1, _), &mut (ref k2, _)| {
k1.cmp(k2) == Ordering::Equal
Expand Down

0 comments on commit 875ce5f

Please sign in to comment.