Skip to content

Commit

Permalink
Fix for upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Jan 4, 2015
1 parent f678635 commit 6963a16
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 32 deletions.
2 changes: 1 addition & 1 deletion phf/src/lib.rs
Expand Up @@ -4,7 +4,7 @@
//! literals, or any of the fixed-size integral types.
#![doc(html_root_url="https://sfackler.github.io/doc")]
#![warn(missing_docs)]
#![feature(macro_rules, phase, globs, old_orphan_check)]
#![feature(macro_rules, phase, globs, old_orphan_check, associated_types)]
#![no_std]

#[phase(plugin, link)]
Expand Down
28 changes: 18 additions & 10 deletions phf/src/map.rs
Expand Up @@ -54,7 +54,9 @@ impl<K, V> fmt::Show for Map<K, V> where K: fmt::Show, V: fmt::Show {
}
}

impl<K, V, Sized? T> Index<T, V> for Map<K, V> where T: Eq + PhfHash + BorrowFrom<K> {
impl<K, V, Sized? T> Index<T> for Map<K, V> where T: Eq + PhfHash + BorrowFrom<K> {
type Output = V;

fn index(&self, k: &T) -> &V {
self.get(k).expect("invalid key")
}
Expand Down Expand Up @@ -131,7 +133,9 @@ pub struct Entries<'a, K:'a, V:'a> {
iter: slice::Iter<'a, (K, V)>,
}

impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> {
impl<'a, K, V> Iterator for Entries<'a, K, V> {
type Item = (&'a K, &'a V);

fn next(&mut self) -> Option<(&'a K, &'a V)> {
self.iter.next().map(|&(ref k, ref v)| (k, v))
}
Expand All @@ -141,20 +145,22 @@ impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> {
}
}

impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a V)> for Entries<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator for Entries<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a V)> {
self.iter.next_back().map(|e| (&e.0, &e.1))
}
}

impl<'a, K, V> ExactSizeIterator<(&'a K, &'a V)> for Entries<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator for Entries<'a, K, V> {}

/// An iterator over the keys in a `Map`.
pub struct Keys<'a, K:'a, V:'a> {
iter: Entries<'a, K, V>,
}

impl<'a, K, V> Iterator<&'a K> for Keys<'a, K, V> {
impl<'a, K, V> Iterator for Keys<'a, K, V> {
type Item = &'a K;

fn next(&mut self) -> Option<&'a K> {
self.iter.next().map(|e| e.0)
}
Expand All @@ -164,20 +170,22 @@ impl<'a, K, V> Iterator<&'a K> for Keys<'a, K, V> {
}
}

impl<'a, K, V> DoubleEndedIterator<&'a K> for Keys<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> {
fn next_back(&mut self) -> Option<&'a K> {
self.iter.next_back().map(|e| e.0)
}
}

impl<'a, K, V> ExactSizeIterator<&'a K> for Keys<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {}

/// An iterator over the values in a `Map`.
pub struct Values<'a, K:'a, V:'a> {
iter: Entries<'a, K, V>,
}

impl<'a, K, V> Iterator<&'a V> for Values<'a, K, V> {
impl<'a, K, V> Iterator for Values<'a, K, V> {
type Item = &'a V;

fn next(&mut self) -> Option<&'a V> {
self.iter.next().map(|e| e.1)
}
Expand All @@ -187,10 +195,10 @@ impl<'a, K, V> Iterator<&'a V> for Values<'a, K, V> {
}
}

impl<'a, K, V> DoubleEndedIterator<&'a V> for Values<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> {
fn next_back(&mut self) -> Option<&'a V> {
self.iter.next_back().map(|e| e.1)
}
}

impl<'a, K, V> ExactSizeIterator<&'a V> for Values<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {}
34 changes: 21 additions & 13 deletions phf/src/ordered_map.rs
Expand Up @@ -61,7 +61,9 @@ impl<K, V> fmt::Show for OrderedMap<K, V> where K: fmt::Show, V: fmt::Show {
}
}

impl<K, V, Sized? T> Index<T, V> for OrderedMap<K, V> where T: Eq + PhfHash + BorrowFrom<K> {
impl<K, V, Sized? T> Index<T> for OrderedMap<K, V> where T: Eq + PhfHash + BorrowFrom<K> {
type Output = V;

fn index(&self, k: &T) -> &V {
self.get(k).expect("invalid key")
}
Expand Down Expand Up @@ -151,7 +153,9 @@ pub struct Entries<'a, K:'a, V:'a> {
iter: slice::Iter<'a, (K, V)>,
}

impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> {
impl<'a, K, V> Iterator for Entries<'a, K, V> {
type Item = (&'a K, &'a V);

fn next(&mut self) -> Option<(&'a K, &'a V)> {
self.iter.next().map(|e| (&e.0, &e.1))
}
Expand All @@ -161,13 +165,13 @@ impl<'a, K, V> Iterator<(&'a K, &'a V)> for Entries<'a, K, V> {
}
}

impl<'a, K, V> DoubleEndedIterator<(&'a K, &'a V)> for Entries<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator for Entries<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a V)> {
self.iter.next_back().map(|e| (&e.0, &e.1))
}
}

impl<'a, K, V> RandomAccessIterator<(&'a K, &'a V)> for Entries<'a, K, V> {
impl<'a, K, V> RandomAccessIterator for Entries<'a, K, V> {
fn indexable(&self) -> uint {
self.iter.indexable()
}
Expand All @@ -177,14 +181,16 @@ impl<'a, K, V> RandomAccessIterator<(&'a K, &'a V)> for Entries<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator<(&'a K, &'a V)> for Entries<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator for Entries<'a, K, V> {}

/// An iterator over the keys in a `OrderedMap`.
pub struct Keys<'a, K:'a, V:'a> {
iter: Entries<'a, K, V>,
}

impl<'a, K, V> Iterator<&'a K> for Keys<'a, K, V> {
impl<'a, K, V> Iterator for Keys<'a, K, V> {
type Item = &'a K;

fn next(&mut self) -> Option<&'a K> {
self.iter.next().map(|e| e.0)
}
Expand All @@ -194,13 +200,13 @@ impl<'a, K, V> Iterator<&'a K> for Keys<'a, K, V> {
}
}

impl<'a, K, V> DoubleEndedIterator<&'a K> for Keys<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> {
fn next_back(&mut self) -> Option<&'a K> {
self.iter.next_back().map(|e| e.0)
}
}

impl<'a, K, V> RandomAccessIterator<&'a K> for Keys<'a, K, V> {
impl<'a, K, V> RandomAccessIterator for Keys<'a, K, V> {
fn indexable(&self) -> uint {
self.iter.indexable()
}
Expand All @@ -210,14 +216,16 @@ impl<'a, K, V> RandomAccessIterator<&'a K> for Keys<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator<&'a K> for Keys<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {}

/// An iterator over the values in a `OrderedMap`.
pub struct Values<'a, K:'a, V:'a> {
iter: Entries<'a, K, V>,
}

impl<'a, K, V> Iterator<&'a V> for Values<'a, K, V> {
impl<'a, K, V> Iterator for Values<'a, K, V> {
type Item = &'a V;

fn next(&mut self) -> Option<&'a V> {
self.iter.next().map(|e| e.1)
}
Expand All @@ -227,13 +235,13 @@ impl<'a, K, V> Iterator<&'a V> for Values<'a, K, V> {
}
}

impl<'a, K, V> DoubleEndedIterator<&'a V> for Values<'a, K, V> {
impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> {
fn next_back(&mut self) -> Option<&'a V> {
self.iter.next_back().map(|e| e.1)
}
}

impl<'a, K, V> RandomAccessIterator<&'a V> for Values<'a, K, V> {
impl<'a, K, V> RandomAccessIterator for Values<'a, K, V> {
fn indexable(&self) -> uint {
self.iter.indexable()
}
Expand All @@ -243,4 +251,4 @@ impl<'a, K, V> RandomAccessIterator<&'a V> for Values<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator<&'a V> for Values<'a, K, V> {}
impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {}
11 changes: 6 additions & 5 deletions phf/src/ordered_set.rs
Expand Up @@ -116,7 +116,9 @@ pub struct Iter<'a, T:'a> {
iter: ordered_map::Keys<'a, T, ()>,
}

impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
impl<'a, T> Iterator for Iter<'a, T> {
type Item = &'a T;

#[inline]
fn next(&mut self) -> Option<&'a T> {
self.iter.next()
Expand All @@ -128,14 +130,14 @@ impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
}
}

impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> {
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
#[inline]
fn next_back(&mut self) -> Option<&'a T> {
self.iter.next_back()
}
}

impl<'a, T> RandomAccessIterator<&'a T> for Iter<'a, T> {
impl<'a, T> RandomAccessIterator for Iter<'a, T> {
#[inline]
fn indexable(&self) -> uint {
self.iter.indexable()
Expand All @@ -147,5 +149,4 @@ impl<'a, T> RandomAccessIterator<&'a T> for Iter<'a, T> {
}
}

impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {}

impl<'a, T> ExactSizeIterator for Iter<'a, T> {}
8 changes: 5 additions & 3 deletions phf/src/set.rs
Expand Up @@ -104,7 +104,9 @@ pub struct Iter<'a, T:'static> {
iter: map::Keys<'a, T, ()>,
}

impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
impl<'a, T> Iterator for Iter<'a, T> {
type Item = &'a T;

fn next(&mut self) -> Option<&'a T> {
self.iter.next()
}
Expand All @@ -114,10 +116,10 @@ impl<'a, T> Iterator<&'a T> for Iter<'a, T> {
}
}

impl<'a, T> DoubleEndedIterator<&'a T> for Iter<'a, T> {
impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
fn next_back(&mut self) -> Option<&'a T> {
self.iter.next_back()
}
}

impl<'a, T> ExactSizeIterator<&'a T> for Iter<'a, T> {}
impl<'a, T> ExactSizeIterator for Iter<'a, T> {}

0 comments on commit 6963a16

Please sign in to comment.