stylo: Add hash module for reexporting HashMap

This commit is contained in:
Manish Goregaokar 2017-08-30 17:00:15 -07:00 committed by Manish Goregaokar
parent c682943900
commit fae5e10643
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
2 changed files with 34 additions and 0 deletions

32
components/style/hash.rs Normal file
View file

@ -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<K, V> = HashMap<K, V, fnv::FnvBuildHasher>;
/// Hash set that uses the FNV hasher
pub type FnvHashSet<T> = HashSet<T, fnv::FnvBuildHasher>;

View file

@ -49,6 +49,7 @@ extern crate bitflags;
extern crate euclid; extern crate euclid;
extern crate fnv; extern crate fnv;
#[cfg(feature = "gecko")] #[macro_use] pub mod gecko_string_cache; #[cfg(feature = "gecko")] #[macro_use] pub mod gecko_string_cache;
extern crate hashglobe;
#[cfg(feature = "servo")] extern crate heapsize; #[cfg(feature = "servo")] extern crate heapsize;
#[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive; #[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive;
extern crate itertools; extern crate itertools;
@ -112,6 +113,7 @@ pub mod font_face;
pub mod font_metrics; pub mod font_metrics;
#[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko; #[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko;
#[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko_bindings; #[cfg(feature = "gecko")] #[allow(unsafe_code)] pub mod gecko_bindings;
pub mod hash;
pub mod invalidation; pub mod invalidation;
#[allow(missing_docs)] // TODO. #[allow(missing_docs)] // TODO.
pub mod logical_geometry; pub mod logical_geometry;