Skip to content

Commit

Permalink
Update for lifetime changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Aug 30, 2014
1 parent f21e2a4 commit af0a11c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
24 changes: 12 additions & 12 deletions phf/src/lib.rs
Expand Up @@ -42,7 +42,7 @@ mod shared;
/// The fields of this struct are public so that they may be initialized by the
/// `phf_map` macro. They are subject to change at any time and should never
/// be accessed directly.
pub struct PhfMap<K, V> {
pub struct PhfMap<K:'static, V:'static> {
#[doc(hidden)]
pub key: u64,
#[doc(hidden)]
Expand Down Expand Up @@ -156,7 +156,7 @@ impl<K, V> PhfMap<K, V> {
}

/// An iterator over the key/value pairs in a `PhfMap`.
pub struct PhfMapEntries<'a, K, V> {
pub struct PhfMapEntries<'a, K:'a, V:'a> {
iter: slice::Items<'a, (K, V)>,
}

Expand All @@ -179,7 +179,7 @@ impl<'a, K, V> DoubleEndedIterator<&'a (K, V)> for PhfMapEntries<'a, K, V> {
impl<'a, K, V> ExactSize<&'a (K, V)> for PhfMapEntries<'a, K, V> {}

/// An iterator over the keys in a `PhfMap`.
pub struct PhfMapKeys<'a, K, V> {
pub struct PhfMapKeys<'a, K:'a, V:'a> {
iter: iter::Map<'a, &'a (K, V), &'a K, PhfMapEntries<'a, K, V>>,
}

Expand All @@ -202,7 +202,7 @@ impl<'a, K, V> DoubleEndedIterator<&'a K> for PhfMapKeys<'a, K, V> {
impl<'a, K, V> ExactSize<&'a K> for PhfMapKeys<'a, K, V> {}

/// An iterator over the values in a `PhfMap`.
pub struct PhfMapValues<'a, K, V> {
pub struct PhfMapValues<'a, K:'a, V:'a> {
iter: iter::Map<'a, &'a (K, V), &'a V, PhfMapEntries<'a, K, V>>,
}

Expand Down Expand Up @@ -249,7 +249,7 @@ impl<'a, K, V> ExactSize<&'a V> for PhfMapValues<'a, K, V> {}
/// The fields of this struct are public so that they may be initialized by the
/// `phf_set` macro. They are subject to change at any time and should never be
/// accessed directly.
pub struct PhfSet<T> {
pub struct PhfSet<T:'static> {
#[doc(hidden)]
pub map: PhfMap<T, ()>
}
Expand Down Expand Up @@ -331,7 +331,7 @@ impl<T> PhfSet<T> {
}

/// An iterator over the values in a `PhfSet`.
pub struct PhfSetValues<'a, T> {
pub struct PhfSetValues<'a, T:'static> {
iter: PhfMapKeys<'a, T, ()>,
}

Expand Down Expand Up @@ -381,7 +381,7 @@ impl<'a, T> ExactSize<&'a T> for PhfSetValues<'a, T> {}
/// The fields of this struct are public so that they may be initialized by the
/// `phf_ordered_map` macro. They are subject to change at any time and should
/// never be accessed directly.
pub struct PhfOrderedMap<K, V> {
pub struct PhfOrderedMap<K:'static, V:'static> {
#[doc(hidden)]
pub key: u64,
#[doc(hidden)]
Expand Down Expand Up @@ -498,7 +498,7 @@ impl<K, V> PhfOrderedMap<K, V> {
}

/// An iterator over the entries in a `PhfOrderedMap`.
pub struct PhfOrderedMapEntries<'a, K, V> {
pub struct PhfOrderedMapEntries<'a, K:'a, V:'a> {
iter: slice::Items<'a, (K, V)>,
}

Expand Down Expand Up @@ -533,7 +533,7 @@ impl<'a, K, V> RandomAccessIterator<&'a (K, V)>
impl<'a, K, V> ExactSize<&'a (K, V)> for PhfOrderedMapEntries<'a, K, V> {}

/// An iterator over the keys in a `PhfOrderedMap`.
pub struct PhfOrderedMapKeys<'a, K, V> {
pub struct PhfOrderedMapKeys<'a, K:'a, V:'a> {
iter: iter::Map<'a, &'a (K, V), &'a K, PhfOrderedMapEntries<'a, K, V>>,
}

Expand Down Expand Up @@ -566,7 +566,7 @@ impl<'a, K, V> RandomAccessIterator<&'a K> for PhfOrderedMapKeys<'a, K, V> {
impl<'a, K, V> ExactSize<&'a K> for PhfOrderedMapKeys<'a, K, V> {}

/// An iterator over the values in a `PhfOrderedMap`.
pub struct PhfOrderedMapValues<'a, K, V> {
pub struct PhfOrderedMapValues<'a, K:'a, V:'a> {
iter: iter::Map<'a, &'a (K, V), &'a V, PhfOrderedMapEntries<'a, K, V>>,
}

Expand Down Expand Up @@ -626,7 +626,7 @@ impl<'a, K, V> ExactSize<&'a V> for PhfOrderedMapValues<'a, K, V> {}
/// The fields of this struct are public so that they may be initialized by the
/// `phf_ordered_set` macro. They are subject to change at any time and should
/// never be accessed directly.
pub struct PhfOrderedSet<T> {
pub struct PhfOrderedSet<T:'static> {
#[doc(hidden)]
pub map: PhfOrderedMap<T, ()>,
}
Expand Down Expand Up @@ -706,7 +706,7 @@ impl<T> PhfOrderedSet<T> {
}

/// An iterator over the values in a `PhfOrderedSet`.
pub struct PhfOrderedSetValues<'a, T> {
pub struct PhfOrderedSetValues<'a, T:'a> {
iter: PhfOrderedMapKeys<'a, T, ()>,
}

Expand Down
16 changes: 8 additions & 8 deletions phf_mac/src/lib.rs
Expand Up @@ -114,7 +114,7 @@ struct HashState {
map: Vec<uint>,
}

fn expand_phf_map(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult> {
fn expand_phf_map(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult+'static> {
let entries = match parse_map(cx, tts) {
Some(entries) => entries,
None => return DummyResult::expr(sp)
Expand All @@ -129,7 +129,7 @@ fn expand_phf_map(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResul
create_map(cx, sp, entries, state)
}

fn expand_phf_set(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult> {
fn expand_phf_set(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult+'static> {
let entries = match parse_set(cx, tts) {
Some(entries) => entries,
None => return DummyResult::expr(sp)
Expand All @@ -144,7 +144,7 @@ fn expand_phf_set(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResul
create_set(cx, sp, entries, state)
}

fn expand_phf_ordered_map(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult> {
fn expand_phf_ordered_map(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult+'static> {
let entries = match parse_map(cx, tts) {
Some(entries) => entries,
None => return DummyResult::expr(sp),
Expand All @@ -159,7 +159,7 @@ fn expand_phf_ordered_map(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<
create_ordered_map(cx, sp, entries, state)
}

fn expand_phf_ordered_set(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult> {
fn expand_phf_ordered_set(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult+'static> {
let entries = match parse_set(cx, tts) {
Some(entries) => entries,
None => return DummyResult::expr(sp)
Expand Down Expand Up @@ -394,7 +394,7 @@ fn try_generate_hash(entries: &[Entry], rng: &mut XorShiftRng) -> Option<HashSta
}

fn create_map(cx: &mut ExtCtxt, sp: Span, entries: Vec<Entry>, state: HashState)
-> Box<MacResult> {
-> Box<MacResult+'static> {
let disps = state.disps.iter().map(|&(d1, d2)| {
quote_expr!(&*cx, ($d1, $d2))
}).collect();
Expand All @@ -415,13 +415,13 @@ fn create_map(cx: &mut ExtCtxt, sp: Span, entries: Vec<Entry>, state: HashState)
}

fn create_set(cx: &mut ExtCtxt, sp: Span, entries: Vec<Entry>, state: HashState)
-> Box<MacResult> {
-> Box<MacResult+'static> {
let map = create_map(cx, sp, entries, state).make_expr().unwrap();
MacExpr::new(quote_expr!(cx, ::phf::PhfSet { map: $map }))
}

fn create_ordered_map(cx: &mut ExtCtxt, sp: Span, entries: Vec<Entry>, state: HashState)
-> Box<MacResult> {
-> Box<MacResult+'static> {
let disps = state.disps.iter().map(|&(d1, d2)| {
quote_expr!(&*cx, ($d1, $d2))
}).collect();
Expand All @@ -445,7 +445,7 @@ fn create_ordered_map(cx: &mut ExtCtxt, sp: Span, entries: Vec<Entry>, state: Ha
}

fn create_ordered_set(cx: &mut ExtCtxt, sp: Span, entries: Vec<Entry>, state: HashState)
-> Box<MacResult> {
-> Box<MacResult+'static> {
let map = create_ordered_map(cx, sp, entries, state).make_expr().unwrap();
MacExpr::new(quote_expr!(cx, ::phf::PhfOrderedSet { map: $map }))
}
Expand Down

0 comments on commit af0a11c

Please sign in to comment.