Skip to content

Commit

Permalink
Merge pull request #36 from alex-gulyas/fix-compilation
Browse files Browse the repository at this point in the history
(fix) Remove default type parameter
  • Loading branch information
reem authored May 28, 2017
2 parents 51650cd + 4f854f2 commit 9452d89
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn _assert_types() {
_assert_debug::<DebugMap>();
}

/// This trait defines the relationship between keys and values in a TypeMap.
/// This trait defines the relationship between keys and values in a `TypeMap`.
///
/// It is implemented for Keys, with a phantom associated type for the values.
pub trait Key: Any {
Expand Down Expand Up @@ -140,7 +140,7 @@ impl<A: UnsafeAnyExt + ?Sized> TypeMap<A> {
}

/// Get the given key's corresponding entry in the map for in-place manipulation.
pub fn entry<'a, K: Key>(&'a mut self) -> Entry<'a, K, A>
pub fn entry<K: Key>(&mut self) -> Entry<K, A>
where K::Value: Any + Implements<A> {
match self.data.entry(TypeId::of::<K>()) {
hash_map::Entry::Occupied(e) => Occupied(OccupiedEntry { data: e, _marker: PhantomData }),
Expand Down Expand Up @@ -174,15 +174,15 @@ impl<A: UnsafeAnyExt + ?Sized> TypeMap<A> {
}
}

/// A view onto an entry in a TypeMap.
/// A view onto an entry in a `TypeMap`.
pub enum Entry<'a, K, A: ?Sized + UnsafeAnyExt + 'a = UnsafeAny> {
/// A view onto an occupied entry in a TypeMap.
Occupied(OccupiedEntry<'a, K, A>),
/// A view onto an unoccupied entry in a TypeMap.
Vacant(VacantEntry<'a, K, A>)
}

impl<'a, K: Key, A: ?Sized + UnsafeAnyExt + 'a = UnsafeAny> Entry<'a, K, A> {
impl<'a, K: Key, A: ?Sized + UnsafeAnyExt + 'a> Entry<'a, K, A> {
/// Ensures a value is in the entry by inserting the default if empty, and returns
/// a mutable reference to the value in the entry.
pub fn or_insert(self, default: K::Value) -> &'a mut K::Value
Expand All @@ -204,13 +204,13 @@ impl<'a, K: Key, A: ?Sized + UnsafeAnyExt + 'a = UnsafeAny> Entry<'a, K, A> {
}
}

/// A view onto an occupied entry in a TypeMap.
/// A view onto an occupied entry in a `TypeMap`.
pub struct OccupiedEntry<'a, K, A: ?Sized + UnsafeAnyExt + 'a = UnsafeAny> {
data: hash_map::OccupiedEntry<'a, TypeId, Box<A>>,
_marker: PhantomData<K>
}

/// A view onto an unoccupied entry in a TypeMap.
/// A view onto an unoccupied entry in a `TypeMap`.
pub struct VacantEntry<'a, K, A: ?Sized + UnsafeAnyExt + 'a = UnsafeAny> {
data: hash_map::VacantEntry<'a, TypeId, Box<A>>,
_marker: PhantomData<K>
Expand Down

0 comments on commit 9452d89

Please sign in to comment.