Skip to content

Commit

Permalink
Fix for upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-morgan committed Jan 7, 2015
1 parent 360bf81 commit c3ae5ac
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 35 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -16,9 +16,9 @@ Example
=======

```rust
#![feature(phase)]
#![feature(plugin)]

#[phase(plugin)]
#[plugin] #[no_link]
extern crate phf_mac;
extern crate phf;

Expand Down
4 changes: 2 additions & 2 deletions phf/src/lib.rs
Expand Up @@ -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;

Expand Down
14 changes: 7 additions & 7 deletions phf/src/map.rs
Expand Up @@ -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! {
Expand Down Expand Up @@ -54,7 +54,7 @@ impl<K, V> fmt::Show for Map<K, V> where K: fmt::Show, V: fmt::Show {
}
}

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

fn index(&self, k: &T) -> &V {
Expand All @@ -74,25 +74,25 @@ impl<K, V> Map<K, V> {
}

/// Determines if `key` is in the `Map`.
pub fn contains_key<Sized? T>(&self, key: &T) -> bool where T: Eq + PhfHash + BorrowFrom<K> {
pub fn contains_key<T: ?Sized>(&self, key: &T) -> bool where T: Eq + PhfHash + BorrowFrom<K> {
self.get(key).is_some()
}

/// Returns a reference to the value that `key` maps to.
pub fn get<Sized? T>(&self, key: &T) -> Option<&V> where T: Eq + PhfHash + BorrowFrom<K> {
pub fn get<T: ?Sized>(&self, key: &T) -> Option<&V> where T: Eq + PhfHash + BorrowFrom<K> {
self.get_entry(key).map(|e| e.1)
}

/// Returns a reference to the map's internal static instance of the given
/// key.
///
/// This can be useful for interning schemes.
pub fn get_key<Sized? T>(&self, key: &T) -> Option<&K> where T: Eq + PhfHash + BorrowFrom<K> {
pub fn get_key<T: ?Sized>(&self, key: &T) -> Option<&K> where T: Eq + PhfHash + BorrowFrom<K> {
self.get_entry(key).map(|e| e.0)
}

/// Like `get`, but returns both the key and the value.
pub fn get_entry<Sized? T>(&self, key: &T) -> Option<(&K, &V)>
pub fn get_entry<T: ?Sized>(&self, key: &T) -> Option<(&K, &V)>
where T: Eq + PhfHash + BorrowFrom<K> {
let (g, f1, f2) = key.phf_hash(self.key);
let (d1, d2) = self.disps[(g % (self.disps.len() as u32)) as uint];
Expand Down
18 changes: 9 additions & 9 deletions phf/src/ordered_map.rs
Expand Up @@ -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! {
Expand Down Expand Up @@ -61,7 +61,7 @@ impl<K, V> fmt::Show for OrderedMap<K, V> where K: fmt::Show, V: fmt::Show {
}
}

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

fn index(&self, k: &T) -> &V {
Expand All @@ -81,37 +81,37 @@ impl<K, V> OrderedMap<K, V> {
}

/// Returns a reference to the value that `key` maps to.
pub fn get<Sized? T>(&self, key: &T) -> Option<&V> where T: Eq + PhfHash + BorrowFrom<K> {
pub fn get<T: ?Sized>(&self, key: &T) -> Option<&V> where T: Eq + PhfHash + BorrowFrom<K> {
self.get_entry(key).map(|e| e.1)
}

/// Returns a reference to the map's internal static instance of the given
/// key.
///
/// This can be useful for interning schemes.
pub fn get_key<Sized? T>(&self, key: &T) -> Option<&K> where T: Eq + PhfHash + BorrowFrom<K> {
pub fn get_key<T: ?Sized>(&self, key: &T) -> Option<&K> where T: Eq + PhfHash + BorrowFrom<K> {
self.get_entry(key).map(|e| e.0)
}

/// Determines if `key` is in the `Map`.
pub fn contains_key<Sized? T>(&self, key: &T) -> bool where T: Eq + PhfHash + BorrowFrom<K> {
pub fn contains_key<T: ?Sized>(&self, key: &T) -> bool where T: Eq + PhfHash + BorrowFrom<K> {
self.get(key).is_some()
}

/// Returns the index of the key within the list used to initialize
/// the ordered map.
pub fn get_index<Sized? T>(&self, key: &T) -> Option<uint>
pub fn get_index<T: ?Sized>(&self, key: &T) -> Option<uint>
where T: Eq + PhfHash + BorrowFrom<K> {
self.get_internal(key).map(|(i, _)| i)
}

/// Like `get`, but returns both the key and the value.
pub fn get_entry<Sized? T>(&self, key: &T) -> Option<(&K, &V)>
pub fn get_entry<T: ?Sized>(&self, key: &T) -> Option<(&K, &V)>
where T: Eq + PhfHash + BorrowFrom<K> {
self.get_internal(key).map(|(_, e)| e)
}

fn get_internal<Sized? T>(&self, key: &T) -> Option<(uint, (&K, &V))>
fn get_internal<T: ?Sized>(&self, key: &T) -> Option<(uint, (&K, &V))>
where T: Eq + PhfHash + BorrowFrom<K> {
let (g, f1, f2) = key.phf_hash(self.key);
let (d1, d2) = self.disps[(g % (self.disps.len() as u32)) as uint];
Expand Down
10 changes: 5 additions & 5 deletions phf/src/ordered_set.rs
Expand Up @@ -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! {
Expand Down Expand Up @@ -67,19 +67,19 @@ impl<T> OrderedSet<T> {
/// key.
///
/// This can be useful for interning schemes.
pub fn get_key<Sized? U>(&self, key: &U) -> Option<&T> where U: Eq + PhfHash + BorrowFrom<T> {
pub fn get_key<U: ?Sized>(&self, key: &U) -> Option<&T> where U: Eq + PhfHash + BorrowFrom<T> {
self.map.get_key(key)
}

/// Returns the index of the key within the list used to initialize
/// the ordered set.
pub fn get_index<Sized? U>(&self, key: &U) -> Option<uint>
pub fn get_index<U: ?Sized>(&self, key: &U) -> Option<uint>
where U: Eq + PhfHash + BorrowFrom<T> {
self.map.get_index(key)
}

/// Returns true if `value` is in the `Set`.
pub fn contains<Sized? U>(&self, value: &U) -> bool where U: Eq + PhfHash + BorrowFrom<T> {
pub fn contains<U: ?Sized>(&self, value: &U) -> bool where U: Eq + PhfHash + BorrowFrom<T> {
self.map.contains_key(value)
}

Expand Down
8 changes: 4 additions & 4 deletions phf/src/set.rs
Expand Up @@ -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! {
Expand Down Expand Up @@ -65,12 +65,12 @@ impl<T> Set<T> {
/// key.
///
/// This can be useful for interning schemes.
pub fn get_key<Sized? U>(&self, key: &U) -> Option<&T> where U: Eq + PhfHash + BorrowFrom<T> {
pub fn get_key<U: ?Sized>(&self, key: &U) -> Option<&T> where U: Eq + PhfHash + BorrowFrom<T> {
self.map.get_key(key)
}

/// Returns true if `value` is in the `Set`.
pub fn contains<Sized? U>(&self, value: &U) -> bool where U: Eq + PhfHash + BorrowFrom<T> {
pub fn contains<U: ?Sized>(&self, value: &U) -> bool where U: Eq + PhfHash + BorrowFrom<T> {
self.map.contains_key(value)
}

Expand Down
4 changes: 2 additions & 2 deletions 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;

Expand Down
2 changes: 1 addition & 1 deletion phf_mac/src/lib.rs
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions phf_shared/src/lib.rs
@@ -1,12 +1,10 @@
#![feature(macro_rules)]
#![no_std]
extern crate core;

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 {
Expand All @@ -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);
}
Expand Down

0 comments on commit c3ae5ac

Please sign in to comment.