difftreelog
feat attrlist update is now lazy
in: trunk
1 file changed
crates/nix-eval/src/lib.rsdiffbeforeafterboth729729730 with_default_context(|c, es| unsafe { get_list_byidx(c, self.0, es, v as u32) }).map(Self)730 with_default_context(|c, es| unsafe { get_list_byidx(c, self.0, es, v as u32) }).map(Self)731 }731 }732 pub fn attrs_update(self, other: Value) -> Result<Self> {732 pub fn attrs_update(self, other: Value/*, ignore_errors: bool*/) -> Result<Self> {733 let a_fields = self.list_fields()?;733 let attrs_update_fn = Self::eval("a: b: a // b")?;734 let b_fields = other.list_fields()?;734735 match (a_fields.len(), b_fields.len()) {736 (_, 0) => return Ok(self),737 (0, _) => return Ok(other),738 _ => {}739 }740 let mut out = HashMap::new();741 for f in a_fields.iter() {742 if b_fields.contains(f) {743 break;744 }745 out.insert(f.as_str(), self.get_field(f)?);746 }747 if out.is_empty() {748 // All fields from lhs are overriden by rhs749 return Ok(other);750 }751 for f in b_fields.iter() {752 out.insert(f.as_str(), other.get_field(f)?);735 attrs_update_fn.call(self)?.call(other).context("attrs update")753 }754 Ok(Self::new_attrs(out))755 }736 }756 pub fn get_field(&self, name: impl AsFieldName) -> Result<Self> {737 pub fn get_field(&self, name: impl AsFieldName) -> Result<Self> {757 if !matches!(self.type_of(), NixType::Attrs) {738 if !matches!(self.type_of(), NixType::Attrs) {