Rust update.

This commit is contained in:
Chris Morgan 2014-11-02 21:45:52 +11:00
parent 512885e502
commit a2560a090f

View file

@ -3,16 +3,16 @@
#![crate_name = "anymap"] #![crate_name = "anymap"]
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(default_type_params)] #![feature(default_type_params)]
#![warn(unnecessary_qualification, non_uppercase_statics, #![warn(unused_qualifications, non_upper_case_globals,
variant_size_difference, unnecessary_typecast, variant_size_differences, unused_typecasts,
missing_doc, unused_result)] missing_docs, unused_results)]
#[cfg(test)] #[cfg(test)]
extern crate test; extern crate test;
use std::any::Any; use std::any::Any;
use std::intrinsics::TypeId; use std::intrinsics::TypeId;
use std::collections::{Collection, HashMap, Mutable}; use std::collections::HashMap;
use std::hash::{Hash, Hasher, Writer}; use std::hash::{Hash, Hasher, Writer};
use std::mem::{transmute, transmute_copy}; use std::mem::{transmute, transmute_copy};
use std::raw::TraitObject; use std::raw::TraitObject;
@ -37,7 +37,7 @@ impl Writer for TypeIdState {
} }
impl Hasher<TypeIdState> for TypeIdHasher { impl Hasher<TypeIdState> for TypeIdHasher {
fn hash<T: Hash<TypeIdState>>(&self, value: &T) -> u64 { fn hash<Sized? T: Hash<TypeIdState>>(&self, value: &T) -> u64 {
let mut state = TypeIdState { let mut state = TypeIdState {
value: 0, value: 0,
}; };
@ -146,20 +146,19 @@ impl AnyMap {
pub fn contains<T: 'static>(&self) -> bool { pub fn contains<T: 'static>(&self) -> bool {
self.data.contains_key(&TypeId::of::<T>()) self.data.contains_key(&TypeId::of::<T>())
} }
}
impl Collection for AnyMap { /// Returns the number of items in the collection.
fn len(&self) -> uint { pub fn len(&self) -> uint {
self.data.len() self.data.len()
} }
fn is_empty(&self) -> bool { /// Returns true if there are no items in the collection.
pub fn is_empty(&self) -> bool {
self.data.is_empty() self.data.is_empty()
} }
}
impl Mutable for AnyMap { /// Removes all items from the collection.
fn clear(&mut self) { pub fn clear(&mut self) {
self.data.clear(); self.data.clear();
} }
} }