Implement Hash for ExternalName.

This allows users to have HashMaps etc. with ExternalNames as keys.
This commit is contained in:
Dan Gohman
2017-11-06 11:34:09 -08:00
parent 1d8df2ed1e
commit 5dda19035d

View File

@@ -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<String> {
const NAME_LENGTH_THRESHOLD: usize = 22;
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum NameRepr {
Short {
length: u8,