From: Chris Morgan Date: Fri, 7 Nov 2014 23:09:21 +0000 (+1100) Subject: Make trait bounds more explicit. X-Git-Tag: 0.9.1~3 X-Git-Url: https://git.chrismorgan.info/anymap/commitdiff_plain/10244cfbba53ae2b5a4043c6f3bbd5f3b9ce8886 Make trait bounds more explicit. --- diff --git a/src/lib.rs b/src/lib.rs index e766913..152a397 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -122,28 +122,28 @@ impl AnyMap { impl AnyMap { /// Retrieve the value stored in the map for the type `T`, if it exists. - pub fn find(&self) -> Option<&T> { + pub fn find(&self) -> Option<&T> { self.data.find(&TypeId::of::()).map(|any| unsafe { any.as_ref_unchecked::() }) } /// Retrieve a mutable reference to the value stored in the map for the type `T`, if it exists. - pub fn find_mut(&mut self) -> Option<&mut T> { + pub fn find_mut(&mut self) -> Option<&mut T> { self.data.find_mut(&TypeId::of::()).map(|any| unsafe { any.as_mut_unchecked::() }) } /// Set the value contained in the map for the type `T`. /// This will override any previous value stored. - pub fn insert(&mut self, value: T) { + pub fn insert(&mut self, value: T) { self.data.insert(TypeId::of::(), box value as Box); } /// Remove the value for the type `T` if it existed. - pub fn remove(&mut self) { + pub fn remove(&mut self) { self.data.remove(&TypeId::of::()); } /// Does a value of type `T` exist? - pub fn contains(&self) -> bool { + pub fn contains(&self) -> bool { self.data.contains_key(&TypeId::of::()) }