diff --git a/README.md b/README.md index a93367ca..60ea7f6e 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ Example ======= ```rust -#![feature(phase)] +#![feature(plugin)] -#[phase(plugin)] +#[plugin] #[no_link] extern crate phf_mac; extern crate phf; diff --git a/phf/src/lib.rs b/phf/src/lib.rs index b81bd496..c1eb02c0 100644 --- a/phf/src/lib.rs +++ b/phf/src/lib.rs @@ -4,10 +4,10 @@ //! 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, associated_types)] +#![feature(old_orphan_check)] #![no_std] -#[phase(plugin, link)] +#[macro_use] extern crate core; extern crate phf_shared; diff --git a/phf/src/map.rs b/phf/src/map.rs index a6e14e75..f60a527b 100644 --- a/phf/src/map.rs +++ b/phf/src/map.rs @@ -12,9 +12,9 @@ use phf_shared; /// `Map`s may be created with the `phf_map` macro: /// /// ```rust -/// # #![feature(phase)] +/// #![feature(plugin)] /// extern crate phf; -/// #[phase(plugin)] +/// #[plugin] #[no_link] /// extern crate phf_mac; /// /// static MY_MAP: phf::Map<&'static str, int> = phf_map! { @@ -54,7 +54,7 @@ impl fmt::Show for Map where K: fmt::Show, V: fmt::Show { } } -impl Index for Map where T: Eq + PhfHash + BorrowFrom { +impl Index for Map where T: Eq + PhfHash + BorrowFrom { type Output = V; fn index(&self, k: &T) -> &V { @@ -74,12 +74,12 @@ impl Map { } /// Determines if `key` is in the `Map`. - pub fn contains_key(&self, key: &T) -> bool where T: Eq + PhfHash + BorrowFrom { + pub fn contains_key(&self, key: &T) -> bool where T: Eq + PhfHash + BorrowFrom { self.get(key).is_some() } /// Returns a reference to the value that `key` maps to. - pub fn get(&self, key: &T) -> Option<&V> where T: Eq + PhfHash + BorrowFrom { + pub fn get(&self, key: &T) -> Option<&V> where T: Eq + PhfHash + BorrowFrom { self.get_entry(key).map(|e| e.1) } @@ -87,12 +87,12 @@ impl Map { /// key. /// /// This can be useful for interning schemes. - pub fn get_key(&self, key: &T) -> Option<&K> where T: Eq + PhfHash + BorrowFrom { + pub fn get_key(&self, key: &T) -> Option<&K> where T: Eq + PhfHash + BorrowFrom { self.get_entry(key).map(|e| e.0) } /// Like `get`, but returns both the key and the value. - pub fn get_entry(&self, key: &T) -> Option<(&K, &V)> + pub fn get_entry(&self, key: &T) -> Option<(&K, &V)> where T: Eq + PhfHash + BorrowFrom { let (g, f1, f2) = key.phf_hash(self.key); let (d1, d2) = self.disps[(g % (self.disps.len() as u32)) as uint]; diff --git a/phf/src/ordered_map.rs b/phf/src/ordered_map.rs index c5be0fbe..231d30d0 100644 --- a/phf/src/ordered_map.rs +++ b/phf/src/ordered_map.rs @@ -17,9 +17,9 @@ use phf_shared; /// `OrderedMap`s may be created with the `phf_ordered_map` macro: /// /// ```rust -/// # #![feature(phase)] +/// #![feature(plugin)] /// extern crate phf; -/// #[phase(plugin)] +/// #[plugin] #[no_link] /// extern crate phf_mac; /// /// static MY_MAP: phf::OrderedMap<&'static str, int> = phf_ordered_map! { @@ -61,7 +61,7 @@ impl fmt::Show for OrderedMap where K: fmt::Show, V: fmt::Show { } } -impl Index for OrderedMap where T: Eq + PhfHash + BorrowFrom { +impl Index for OrderedMap where T: Eq + PhfHash + BorrowFrom { type Output = V; fn index(&self, k: &T) -> &V { @@ -81,7 +81,7 @@ impl OrderedMap { } /// Returns a reference to the value that `key` maps to. - pub fn get(&self, key: &T) -> Option<&V> where T: Eq + PhfHash + BorrowFrom { + pub fn get(&self, key: &T) -> Option<&V> where T: Eq + PhfHash + BorrowFrom { self.get_entry(key).map(|e| e.1) } @@ -89,29 +89,29 @@ impl OrderedMap { /// key. /// /// This can be useful for interning schemes. - pub fn get_key(&self, key: &T) -> Option<&K> where T: Eq + PhfHash + BorrowFrom { + pub fn get_key(&self, key: &T) -> Option<&K> where T: Eq + PhfHash + BorrowFrom { self.get_entry(key).map(|e| e.0) } /// Determines if `key` is in the `Map`. - pub fn contains_key(&self, key: &T) -> bool where T: Eq + PhfHash + BorrowFrom { + pub fn contains_key(&self, key: &T) -> bool where T: Eq + PhfHash + BorrowFrom { self.get(key).is_some() } /// Returns the index of the key within the list used to initialize /// the ordered map. - pub fn get_index(&self, key: &T) -> Option + pub fn get_index(&self, key: &T) -> Option where T: Eq + PhfHash + BorrowFrom { self.get_internal(key).map(|(i, _)| i) } /// Like `get`, but returns both the key and the value. - pub fn get_entry(&self, key: &T) -> Option<(&K, &V)> + pub fn get_entry(&self, key: &T) -> Option<(&K, &V)> where T: Eq + PhfHash + BorrowFrom { self.get_internal(key).map(|(_, e)| e) } - fn get_internal(&self, key: &T) -> Option<(uint, (&K, &V))> + fn get_internal(&self, key: &T) -> Option<(uint, (&K, &V))> where T: Eq + PhfHash + BorrowFrom { let (g, f1, f2) = key.phf_hash(self.key); let (d1, d2) = self.disps[(g % (self.disps.len() as u32)) as uint]; diff --git a/phf/src/ordered_set.rs b/phf/src/ordered_set.rs index acc60a9a..5093425f 100644 --- a/phf/src/ordered_set.rs +++ b/phf/src/ordered_set.rs @@ -14,9 +14,9 @@ use {PhfHash, OrderedMap}; /// `OrderedSet`s may be created with the `phf_ordered_set` macro: /// /// ```rust -/// # #![feature(phase)] +/// #![feature(plugin)] /// extern crate phf; -/// #[phase(plugin)] +/// #[plugin] #[no_link] /// extern crate phf_mac; /// /// static MY_SET: phf::OrderedSet<&'static str> = phf_ordered_set! { @@ -67,19 +67,19 @@ impl OrderedSet { /// key. /// /// This can be useful for interning schemes. - pub fn get_key(&self, key: &U) -> Option<&T> where U: Eq + PhfHash + BorrowFrom { + pub fn get_key(&self, key: &U) -> Option<&T> where U: Eq + PhfHash + BorrowFrom { self.map.get_key(key) } /// Returns the index of the key within the list used to initialize /// the ordered set. - pub fn get_index(&self, key: &U) -> Option + pub fn get_index(&self, key: &U) -> Option where U: Eq + PhfHash + BorrowFrom { self.map.get_index(key) } /// Returns true if `value` is in the `Set`. - pub fn contains(&self, value: &U) -> bool where U: Eq + PhfHash + BorrowFrom { + pub fn contains(&self, value: &U) -> bool where U: Eq + PhfHash + BorrowFrom { self.map.contains_key(value) } diff --git a/phf/src/set.rs b/phf/src/set.rs index 099f985d..a8171476 100644 --- a/phf/src/set.rs +++ b/phf/src/set.rs @@ -12,9 +12,9 @@ use Map; /// `Set`s may be created with the `phf_set` macro: /// /// ```rust -/// # #![feature(phase)] +/// #![feature(plugin)] /// extern crate phf; -/// #[phase(plugin)] +/// #[plugin] #[no_link] /// extern crate phf_mac; /// /// static MY_SET: phf::Set<&'static str> = phf_set! { @@ -65,12 +65,12 @@ impl Set { /// key. /// /// This can be useful for interning schemes. - pub fn get_key(&self, key: &U) -> Option<&T> where U: Eq + PhfHash + BorrowFrom { + pub fn get_key(&self, key: &U) -> Option<&T> where U: Eq + PhfHash + BorrowFrom { self.map.get_key(key) } /// Returns true if `value` is in the `Set`. - pub fn contains(&self, value: &U) -> bool where U: Eq + PhfHash + BorrowFrom { + pub fn contains(&self, value: &U) -> bool where U: Eq + PhfHash + BorrowFrom { self.map.contains_key(value) } diff --git a/phf/tests/test.rs b/phf/tests/test.rs index bbbe4dd6..8c382b87 100644 --- a/phf/tests/test.rs +++ b/phf/tests/test.rs @@ -1,6 +1,6 @@ -#![feature(phase, macro_rules)] +#![feature(plugin)] -#[phase(plugin)] +#[plugin] #[no_link] extern crate phf_mac; extern crate phf; diff --git a/phf_mac/src/lib.rs b/phf_mac/src/lib.rs index dac17bb0..068571a9 100644 --- a/phf_mac/src/lib.rs +++ b/phf_mac/src/lib.rs @@ -2,7 +2,7 @@ //! //! See the documentation for the `phf` crate for more details. #![doc(html_root_url="http://sfackler.github.io/doc")] -#![feature(plugin_registrar, quote, default_type_params, macro_rules, old_orphan_check)] +#![feature(plugin_registrar, quote, old_orphan_check)] #![allow(unknown_features)] extern crate rand; diff --git a/phf_shared/src/lib.rs b/phf_shared/src/lib.rs index f4fc005a..18d80d6e 100644 --- a/phf_shared/src/lib.rs +++ b/phf_shared/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(macro_rules)] #![no_std] extern crate core; @@ -6,7 +5,6 @@ use core::slice::AsSlice; use core::str::StrExt; use core::hash::Writer; use core::hash::sip::{self, SipState}; -use core::kinds::Sized; #[inline] pub fn displace(f1: u32, f2: u32, d1: u32, d2: u32) -> u32 { @@ -24,7 +22,7 @@ fn split(hash: u64) -> (u32, u32, u32) { } /// A trait implemented by types which can be used in PHF data structures -pub trait PhfHash for Sized? { +pub trait PhfHash { /// Hashes the value of `self`, factoring in a seed fn phf_hash(&self, seed: u64) -> (u32, u32, u32); }