Implement Hash for ExternalName.
This allows users to have HashMaps etc. with ExternalNames as keys.
This commit is contained in:
@@ -15,7 +15,7 @@ use std::ascii::AsciiExt;
|
|||||||
/// External names can also serve as a primitive testing and debugging tool.
|
/// External names can also serve as a primitive testing and debugging tool.
|
||||||
/// In particular, many `.cton` test files use function names to identify
|
/// In particular, many `.cton` test files use function names to identify
|
||||||
/// functions.
|
/// functions.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default, Hash)]
|
||||||
pub struct ExternalName(NameRepr);
|
pub struct ExternalName(NameRepr);
|
||||||
|
|
||||||
impl ExternalName {
|
impl ExternalName {
|
||||||
@@ -69,7 +69,7 @@ fn try_as_name(bytes: &[u8]) -> Option<String> {
|
|||||||
|
|
||||||
const NAME_LENGTH_THRESHOLD: usize = 22;
|
const NAME_LENGTH_THRESHOLD: usize = 22;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
enum NameRepr {
|
enum NameRepr {
|
||||||
Short {
|
Short {
|
||||||
length: u8,
|
length: u8,
|
||||||
|
|||||||
Reference in New Issue
Block a user