From e2152739cbdd471116d88bb4a9cea4cdfede1e42 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 30 Mar 2015 21:15:35 -0700 Subject: [PATCH] Stabilize phf --- phf/src/lib.rs | 1 - phf/src/ordered_map.rs | 32 +------------------------------- phf/src/ordered_set.rs | 14 +------------- phf_macros/tests/test.rs | 7 +------ 4 files changed, 3 insertions(+), 51 deletions(-) diff --git a/phf/src/lib.rs b/phf/src/lib.rs index 42bf96b9..570d6561 100644 --- a/phf/src/lib.rs +++ b/phf/src/lib.rs @@ -4,7 +4,6 @@ //! `phf_macros` crate or via code generation in the `phf_codegen` crate. See //! the documentation of those crates for more details. #![doc(html_root_url="https://sfackler.github.io/rust-phf/doc")] -#![feature(core)] #![warn(missing_docs)] extern crate debug_builders; diff --git a/phf/src/ordered_map.rs b/phf/src/ordered_map.rs index 5fd266a8..afbecc8a 100644 --- a/phf/src/ordered_map.rs +++ b/phf/src/ordered_map.rs @@ -2,7 +2,7 @@ use debug_builders::DebugMap; use std::prelude::v1::*; use std::borrow::Borrow; -use std::iter::{IntoIterator, RandomAccessIterator}; +use std::iter::IntoIterator; use std::ops::Index; use std::fmt; use std::slice; @@ -156,16 +156,6 @@ impl<'a, K, V> DoubleEndedIterator for Entries<'a, K, V> { } } -impl<'a, K, V> RandomAccessIterator for Entries<'a, K, V> { - fn indexable(&self) -> usize { - self.iter.indexable() - } - - fn idx(&mut self, index: usize) -> Option<(&'a K, &'a V)> { - self.iter.idx(index).map(|e| (&e.0, &e.1)) - } -} - impl<'a, K, V> ExactSizeIterator for Entries<'a, K, V> {} /// An iterator over the keys in a `OrderedMap`. @@ -191,16 +181,6 @@ impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> { } } -impl<'a, K, V> RandomAccessIterator for Keys<'a, K, V> { - fn indexable(&self) -> usize { - self.iter.indexable() - } - - fn idx(&mut self, index: usize) -> Option<&'a K> { - self.iter.idx(index).map(|e| e.0) - } -} - impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {} /// An iterator over the values in a `OrderedMap`. @@ -226,14 +206,4 @@ impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> { } } -impl<'a, K, V> RandomAccessIterator for Values<'a, K, V> { - fn indexable(&self) -> usize { - self.iter.indexable() - } - - fn idx(&mut self, index: usize) -> Option<&'a V> { - self.iter.idx(index).map(|e| e.1) - } -} - impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {} diff --git a/phf/src/ordered_set.rs b/phf/src/ordered_set.rs index 75ebe052..44fcbba1 100644 --- a/phf/src/ordered_set.rs +++ b/phf/src/ordered_set.rs @@ -2,7 +2,7 @@ use debug_builders::DebugSet; use std::prelude::v1::*; use std::borrow::Borrow; -use std::iter::{IntoIterator, RandomAccessIterator}; +use std::iter::IntoIterator; use std::fmt; use ordered_map; use {PhfHash, OrderedMap}; @@ -122,16 +122,4 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { } } -impl<'a, T> RandomAccessIterator for Iter<'a, T> { - #[inline] - fn indexable(&self) -> usize { - self.iter.indexable() - } - - #[inline] - fn idx(&mut self, index: usize) -> Option<&'a T> { - self.iter.idx(index) - } -} - impl<'a, T> ExactSizeIterator for Iter<'a, T> {} diff --git a/phf_macros/tests/test.rs b/phf_macros/tests/test.rs index f905fa25..6cf04910 100644 --- a/phf_macros/tests/test.rs +++ b/phf_macros/tests/test.rs @@ -1,4 +1,4 @@ -#![feature(plugin, core)] +#![feature(plugin)] #![plugin(phf_macros)] extern crate phf; @@ -288,8 +288,6 @@ mod set { } mod ordered_map { - use std::iter::RandomAccessIterator; - use phf; #[allow(dead_code)] @@ -324,7 +322,6 @@ mod ordered_map { assert_eq!(Some(0), MAP.get_index(&"foo")); assert_eq!(Some(2), MAP.get_index(&"baz")); assert_eq!(None, MAP.get_index(&"xyz")); - assert_eq!(&"baz", MAP.keys().idx(MAP.get_index(&"baz").unwrap()).unwrap()); assert_eq!(Some(0), MAP.get_index(&*"foo".to_string())); assert_eq!(Some(2), MAP.get_index(&*"baz".to_string())); @@ -403,7 +400,6 @@ mod ordered_map { } mod ordered_set { - use std::iter::RandomAccessIterator; use phf; #[allow(dead_code)] @@ -440,7 +436,6 @@ mod ordered_set { assert_eq!(Some(0), SET.get_index(&"foo")); assert_eq!(Some(2), SET.get_index(&"baz")); assert_eq!(None, SET.get_index(&"xyz")); - assert_eq!(&"baz", SET.iter().idx(SET.get_index(&"baz").unwrap()).unwrap()); assert_eq!(Some(0), SET.get_index(&*"foo".to_string())); assert_eq!(Some(2), SET.get_index(&*"baz".to_string()));