diff --git a/components/style/hash.rs b/components/style/hash.rs new file mode 100644 index 000000000000..305357a85b23 --- /dev/null +++ b/components/style/hash.rs @@ -0,0 +1,32 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//! Reexports of hashglobe types in Gecko mode, and stdlib hashmap shims in Servo mode +//! +//! Can go away when the stdlib gets fallible collections +//! https://github.com/rust-lang/rfcs/pull/2116 + +use fnv; + +#[cfg(feature = "gecko")] +pub use hashglobe::hash_map::HashMap; +#[cfg(feature = "gecko")] +pub use hashglobe::hash_set::HashSet; + + +#[cfg(feature = "servo")] +pub use hashglobe::fake::{HashMap, HashSet}; + +/// Appropriate reexports of hash_map types +pub mod map { + #[cfg(feature = "gecko")] + pub use hashglobe::hash_map::{Entry, Iter}; + #[cfg(feature = "servo")] + pub use std::collections::hash_map::{Entry, Iter}; +} + +/// Hash map that uses the FNV hasher +pub type FnvHashMap = HashMap; +/// Hash set that uses the FNV hasher +pub type FnvHashSet = HashSet; diff --git a/components/style/lib.rs b/components/style/lib.rs index 0f8a21651d25..e70a92d5bbc0 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -49,6 +49,7 @@ extern crate bitflags; extern crate euclid; extern crate fnv; #[cfg(feature = "gecko")] #[macro_use] pub mod gecko_string_cache; +extern crate hashglobe; #[cfg(feature = "servo")] extern crate heapsize; #[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive; extern crate itertools; @@ -112,6 +113,7 @@ pub mod font_face; pub mod font_metrics; #[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko; #[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko_bindings; +pub mod hash; pub mod invalidation; #[allow(missing_docs)] // TODO. pub mod logical_geometry;