Chris Morgan
›
Git
›
anymap
› commitdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
patch
|
inline
| side by side (from parent 1:
8e12aff
)
commit
grep
author
committer
pickaxe
?
search:
re
0.9.11: Rust update
0.9.11
author
Chris Morgan
<me@chrismorgan.info>
Tue, 24 Feb 2015 00:59:02 +0000
committer
Chris Morgan
<me@chrismorgan.info>
Tue, 24 Feb 2015 00:59:02 +0000
Cargo.toml
patch
|
blob
|
history
src/lib.rs
patch
|
blob
|
history
diff --git
a/Cargo.toml
b/Cargo.toml
index 6b34ed71457f2926c465cd793120c3a24a854f8c..606aace12710f73fbe16fe579b9a77db264aec38 100644
(file)
--- a/
Cargo.toml
+++ b/
Cargo.toml
@@
-1,6
+1,6
@@
[package]
name = "anymap"
[package]
name = "anymap"
-version = "0.9.1
0
"
+version = "0.9.1
1
"
authors = ["Chris Morgan <me@chrismorgan.info>"]
description = "A safe and convenient store for one value of each type"
#documentation = "http://www.rust-ci.org/chris-morgan/anymap/doc/anymap/index.html"
authors = ["Chris Morgan <me@chrismorgan.info>"]
description = "A safe and convenient store for one value of each type"
#documentation = "http://www.rust-ci.org/chris-morgan/anymap/doc/anymap/index.html"
diff --git
a/src/lib.rs
b/src/lib.rs
index c4c2161ae650b690cba8909458fdd52c9f71e3fb..135fa0a8569622e605780f022c890c172abc0827 100644
(file)
--- a/
src/lib.rs
+++ b/
src/lib.rs
@@
-13,10
+13,11
@@
use std::any::{Any, TypeId};
use std::mem::forget;
use std::collections::HashMap;
use std::collections::hash_map;
use std::mem::forget;
use std::collections::HashMap;
use std::collections::hash_map;
-use std::hash::
{Hasher, Writer}
;
+use std::hash::
Hasher
;
use std::collections::hash_state::HashState;
use std::mem::transmute;
use std::raw::TraitObject;
use std::collections::hash_state::HashState;
use std::mem::transmute;
use std::raw::TraitObject;
+use std::marker::PhantomData;
struct TypeIdHasher {
value: u64,
struct TypeIdHasher {
value: u64,
@@
-32,7
+33,7
@@
impl HashState for TypeIdState {
}
}
}
}
-impl
Writ
er for TypeIdHasher {
+impl
Hash
er for TypeIdHasher {
#[inline(always)]
fn write(&mut self, bytes: &[u8]) {
// This expects to receive one and exactly one 64-bit value
#[inline(always)]
fn write(&mut self, bytes: &[u8]) {
// This expects to receive one and exactly one 64-bit value
@@
-43,13
+44,8
@@
impl Writer for TypeIdHasher {
1)
}
}
1)
}
}
-}
-
-impl Hasher for TypeIdHasher {
- type Output = u64;
-
- fn reset(&mut self) { }
+ #[inline(always)]
fn finish(&self) -> u64 { self.value }
}
fn finish(&self) -> u64 { self.value }
}
@@
-268,8
+264,14
@@
impl AnyMap {
#[stable]
pub fn entry<T: Any + 'static>(&mut self) -> Entry<T> {
match self.data.entry(TypeId::of::<T>()) {
#[stable]
pub fn entry<T: Any + 'static>(&mut self) -> Entry<T> {
match self.data.entry(TypeId::of::<T>()) {
- hash_map::Entry::Occupied(e) => Entry::Occupied(OccupiedEntry { entry: e }),
- hash_map::Entry::Vacant(e) => Entry::Vacant(VacantEntry { entry: e }),
+ hash_map::Entry::Occupied(e) => Entry::Occupied(OccupiedEntry {
+ entry: e,
+ type_: PhantomData,
+ }),
+ hash_map::Entry::Vacant(e) => Entry::Vacant(VacantEntry {
+ entry: e,
+ type_: PhantomData,
+ }),
}
}
}
}
@@
-312,12
+314,14
@@
impl AnyMap {
#[stable]
pub struct OccupiedEntry<'a, V: 'a> {
entry: hash_map::OccupiedEntry<'a, TypeId, Box<Any + 'static>>,
#[stable]
pub struct OccupiedEntry<'a, V: 'a> {
entry: hash_map::OccupiedEntry<'a, TypeId, Box<Any + 'static>>,
+ type_: PhantomData<V>,
}
/// A view into a single empty location in an AnyMap
#[stable]
pub struct VacantEntry<'a, V: 'a> {
entry: hash_map::VacantEntry<'a, TypeId, Box<Any + 'static>>,
}
/// A view into a single empty location in an AnyMap
#[stable]
pub struct VacantEntry<'a, V: 'a> {
entry: hash_map::VacantEntry<'a, TypeId, Box<Any + 'static>>,
+ type_: PhantomData<V>,
}
/// A view into a single location in an AnyMap, which may be vacant or occupied
}
/// A view into a single location in an AnyMap, which may be vacant or occupied