From 5dda19035d8d037e326adb697d3c613ca6a4a620 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 6 Nov 2017 11:34:09 -0800 Subject: [PATCH] Implement Hash for ExternalName. This allows users to have HashMaps etc. with ExternalNames as keys. --- lib/cretonne/src/ir/extname.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cretonne/src/ir/extname.rs b/lib/cretonne/src/ir/extname.rs index bd8c4e631e..273006b570 100644 --- a/lib/cretonne/src/ir/extname.rs +++ b/lib/cretonne/src/ir/extname.rs @@ -15,7 +15,7 @@ use std::ascii::AsciiExt; /// External names can also serve as a primitive testing and debugging tool. /// In particular, many `.cton` test files use function names to identify /// functions. -#[derive(Debug, Clone, PartialEq, Eq, Default)] +#[derive(Debug, Clone, PartialEq, Eq, Default, Hash)] pub struct ExternalName(NameRepr); impl ExternalName { @@ -69,7 +69,7 @@ fn try_as_name(bytes: &[u8]) -> Option { const NAME_LENGTH_THRESHOLD: usize = 22; -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] enum NameRepr { Short { length: u8,