fix(tvix/value): ensure only string values of NixString are hashed
Change-Id: I1b97cf5a9e4e235fac72a507de49a8df508bcaa1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6138 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
fb3d024d75
commit
58db7e3a65
1 changed files with 8 additions and 1 deletions
|
@ -1,9 +1,10 @@
|
|||
use std::hash::Hash;
|
||||
use std::{borrow::Cow, fmt::Display};
|
||||
|
||||
/// This module implements Nix language strings and their different
|
||||
/// backing implementations.
|
||||
|
||||
#[derive(Clone, Debug, Hash, Eq, Ord)]
|
||||
#[derive(Clone, Debug, Eq, Ord)]
|
||||
pub enum NixString {
|
||||
Static(&'static str),
|
||||
Heap(String),
|
||||
|
@ -33,6 +34,12 @@ impl From<String> for NixString {
|
|||
}
|
||||
}
|
||||
|
||||
impl Hash for NixString {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.as_str().hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
impl NixString {
|
||||
pub const NAME: Self = NixString::Static("name");
|
||||
pub const VALUE: Self = NixString::Static("value");
|
||||
|
|
Loading…
Reference in a new issue