From 3d54c0710f56193299f6eb6aa173585189a6bb86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 7 Aug 2017 13:50:05 +0200 Subject: [PATCH] style: Make PrecomputedHasher fail loudly and with error messages when used incorrectly. --- components/style/selector_map.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/style/selector_map.rs b/components/style/selector_map.rs index d4775f315ab..193196c488a 100644 --- a/components/style/selector_map.rs +++ b/components/style/selector_map.rs @@ -25,12 +25,12 @@ use stylist::Rule; /// A hasher implementation that doesn't hash anything, because it expects its /// input to be a suitable u32 hash. pub struct PrecomputedHasher { - hash: u32, + hash: Option, } impl Default for PrecomputedHasher { fn default() -> Self { - Self { hash: 0 } + Self { hash: None } } } @@ -43,17 +43,19 @@ pub type PrecomputedHashSet = HashSet u64 { - self.hash as u64 + self.hash.expect("PrecomputedHasher wasn't fed?") as u64 } }