Skip to content

Commit

Permalink
Stabilize phf
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Mar 31, 2015
1 parent 0b68ea5 commit e215273
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 51 deletions.
1 change: 0 additions & 1 deletion phf/src/lib.rs
Expand Up @@ -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;
Expand Down
32 changes: 1 addition & 31 deletions phf/src/ordered_map.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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`.
Expand All @@ -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`.
Expand All @@ -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> {}
14 changes: 1 addition & 13 deletions phf/src/ordered_set.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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> {}
7 changes: 1 addition & 6 deletions phf_macros/tests/test.rs
@@ -1,4 +1,4 @@
#![feature(plugin, core)]
#![feature(plugin)]
#![plugin(phf_macros)]

extern crate phf;
Expand Down Expand Up @@ -288,8 +288,6 @@ mod set {
}

mod ordered_map {
use std::iter::RandomAccessIterator;

use phf;

#[allow(dead_code)]
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -403,7 +400,6 @@ mod ordered_map {
}

mod ordered_set {
use std::iter::RandomAccessIterator;
use phf;

#[allow(dead_code)]
Expand Down Expand Up @@ -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()));
Expand Down

0 comments on commit e215273

Please sign in to comment.