refactor(tvix/value): ensure internal attrs representation is hidden
Wraps the attrs representation in an additional newtype struct with a private field in order to hide the representation from other modules. This is done in order to avoid accidental leakage of the internals outside of value::attrs. Change-Id: I68d1d02514aa0443df4c39801001a3f1f6cc5d5c Reviewed-on: https://cl.tvl.fyi/c/depot/+/6146 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
9407af5684
commit
a0cbc78a83
2 changed files with 53 additions and 47 deletions
|
|
@ -5,7 +5,7 @@ fn test_empty_attrs() {
|
|||
let attrs = NixAttrs::construct(0, vec![]).expect("empty attr construction should succeed");
|
||||
|
||||
assert!(
|
||||
matches!(attrs, NixAttrs::Empty),
|
||||
matches!(attrs, NixAttrs(AttrsRep::Empty)),
|
||||
"empty attribute set should use optimised representation"
|
||||
);
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ fn test_simple_attrs() {
|
|||
.expect("simple attr construction should succeed");
|
||||
|
||||
assert!(
|
||||
matches!(attrs, NixAttrs::Map(_)),
|
||||
matches!(attrs, NixAttrs(AttrsRep::Map(_))),
|
||||
"simple attribute set should use map representation",
|
||||
)
|
||||
}
|
||||
|
|
@ -43,7 +43,8 @@ fn test_kv_attrs() {
|
|||
.expect("constructing K/V pair attrs should succeed");
|
||||
|
||||
match kv_attrs {
|
||||
NixAttrs::KV { name, value } if name == meaning_val || value == forty_two_val => {}
|
||||
NixAttrs(AttrsRep::KV { name, value }) if name == meaning_val || value == forty_two_val => {
|
||||
}
|
||||
|
||||
_ => panic!(
|
||||
"K/V attribute set should use optimised representation, but got {:?}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue