fix: attrset update
This commit is contained in:
@@ -144,7 +144,7 @@ fn test_attrs() {
|
|||||||
test_expr("{ a.b = 1; } ? a.b", boolean!(true));
|
test_expr("{ a.b = 1; } ? a.b", boolean!(true));
|
||||||
test_expr(
|
test_expr(
|
||||||
"{ a.b = 1; } // { a.c = 2 }",
|
"{ a.b = 1; } // { a.c = 2 }",
|
||||||
attrs! { symbol!("a") => attrs!{ symbol!("b") => int!(1), symbol!("c") => int!(2) } },
|
attrs! { symbol!("a") => attrs!{ symbol!("c") => int!(2) } },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +164,6 @@ fn test_let() {
|
|||||||
test_expr(r#"let a = { a = 1; }; b = "a"; in a.${b}"#, int!(1));
|
test_expr(r#"let a = { a = 1; }; b = "a"; in a.${b}"#, int!(1));
|
||||||
test_expr(
|
test_expr(
|
||||||
r#"let b = "c"; in { a.b = 1; } // { a."a${b}" = 2 }"}"#,
|
r#"let b = "c"; in { a.b = 1; } // { a."a${b}" = 2 }"}"#,
|
||||||
attrs! { symbol!("a") => attrs!{ symbol!("b") => int!(1), symbol!("ac") => int!(2) } },
|
attrs! { symbol!("a") => attrs!{ symbol!("ac") => int!(2) } },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,8 @@ impl AttrSet {
|
|||||||
|
|
||||||
pub fn update(mut self, other: AttrSet) -> AttrSet {
|
pub fn update(mut self, other: AttrSet) -> AttrSet {
|
||||||
for (k, v) in other.data.iter() {
|
for (k, v) in other.data.iter() {
|
||||||
if let Some(attr) = self.data.get(k) {
|
|
||||||
let new_attr = attr.clone().update(v.clone());
|
|
||||||
self.data.insert_mut(k.clone(), new_attr);
|
|
||||||
} else {
|
|
||||||
self.push_attr(k.clone(), v.clone())
|
self.push_attr(k.clone(), v.clone())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user