diff options
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r-- | tvix/eval/src/value/attrs.rs | 4 | ||||
-rw-r--r-- | tvix/eval/src/value/json.rs | 6 | ||||
-rw-r--r-- | tvix/eval/src/value/list.rs | 4 | ||||
-rw-r--r-- | tvix/eval/src/value/mod.rs | 13 | ||||
-rw-r--r-- | tvix/eval/src/value/string.rs | 8 |
5 files changed, 17 insertions, 18 deletions
diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs index f3638e69c214..9e891135c9c2 100644 --- a/tvix/eval/src/value/attrs.rs +++ b/tvix/eval/src/value/attrs.rs @@ -301,7 +301,7 @@ impl NixAttrs { /// Same as iter(), but marks call sites which rely on the /// iteration being lexicographic. - pub fn iter_sorted<'a>(&'a self) -> Iter<KeyValue<'a>> { + pub fn iter_sorted(&self) -> Iter<KeyValue<'_>> { self.iter() } @@ -399,7 +399,7 @@ impl NixAttrs { // /another/ set with a __toString attr. let s = generators::request_string_coerce(co, result, kind).await; - return Some(s.ok()?); + return s.ok(); } None diff --git a/tvix/eval/src/value/json.rs b/tvix/eval/src/value/json.rs index 1290cce14e48..bff04487fa50 100644 --- a/tvix/eval/src/value/json.rs +++ b/tvix/eval/src/value/json.rs @@ -12,7 +12,7 @@ use serde_json::Value as Json; // name clash with *our* `Value` use serde_json::{Map, Number}; impl Value { - pub(crate) async fn to_json( + pub(crate) async fn into_json( self, co: &GenCo, ) -> Result<Result<Json, CatchableErrorKind>, ErrorKind> { @@ -86,8 +86,8 @@ impl Value { /// Generator version of the above, which wraps responses in /// Value::Json. - pub(crate) async fn to_json_generator(self, co: GenCo) -> Result<Value, ErrorKind> { - match self.to_json(&co).await? { + pub(crate) async fn into_json_generator(self, co: GenCo) -> Result<Value, ErrorKind> { + match self.into_json(&co).await? { Err(cek) => Ok(Value::Catchable(cek)), Ok(json) => Ok(Value::Json(json)), } diff --git a/tvix/eval/src/value/list.rs b/tvix/eval/src/value/list.rs index cfaefff82195..627956399399 100644 --- a/tvix/eval/src/value/list.rs +++ b/tvix/eval/src/value/list.rs @@ -59,7 +59,7 @@ impl NixList { stack_slice.len(), ); - NixList(Rc::new(Vector::from_iter(stack_slice.into_iter()))) + NixList(Rc::new(Vector::from_iter(stack_slice))) } pub fn iter(&self) -> vector::Iter<Value> { @@ -76,7 +76,7 @@ impl NixList { #[deprecated(note = "callers should avoid constructing from Vec")] pub fn from_vec(vs: Vec<Value>) -> Self { - Self(Rc::new(Vector::from_iter(vs.into_iter()))) + Self(Rc::new(Vector::from_iter(vs))) } /// Asynchronous sorting algorithm in which the comparator can make use of diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index 9b6e522dd0a6..3a9dcf2c8da1 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -97,7 +97,7 @@ where Value: From<V>, { fn from(v: Result<V, CatchableErrorKind>) -> Value { - v.map_or_else(|cek| Value::Catchable(cek), |v| v.into()) + v.map_or_else(Value::Catchable, |v| v.into()) } } @@ -362,7 +362,7 @@ impl Value { kind, }), - (c @ Value::Catchable(_), _) => return Ok(c), + (c @ Value::Catchable(_), _) => Ok(c), (Value::AttrNotFound, _) | (Value::Blueprint(_), _) @@ -762,11 +762,10 @@ fn total_fmt_float<F: std::fmt::Write>(num: f64, mut f: F) -> std::fmt::Result { if !new_s.is_empty() { s = &mut new_s } - } - // else, if this is not scientific notation, and there's a - // decimal point, make sure we really drop trailing zeroes. - // In some cases, lexical_core doesn't. - else if s.contains(&b'.') { + } else if s.contains(&b'.') { + // else, if this is not scientific notation, and there's a + // decimal point, make sure we really drop trailing zeroes. + // In some cases, lexical_core doesn't. for (i, c) in s.iter().enumerate() { // at `.`` if c == &b'.' { diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs index 8ffbc2a5325c..c8624a6d62d1 100644 --- a/tvix/eval/src/value/string.rs +++ b/tvix/eval/src/value/string.rs @@ -176,10 +176,10 @@ fn nix_escape_char(ch: char, next: Option<&char>) -> Option<&'static str> { /// parsed as identifiers. See also cppnix commit /// b72bc4a972fe568744d98b89d63adcd504cb586c. fn is_keyword(s: &str) -> bool { - match s { - "if" | "then" | "else" | "assert" | "with" | "let" | "in" | "rec" | "inherit" => true, - _ => false, - } + matches!( + s, + "if" | "then" | "else" | "assert" | "with" | "let" | "in" | "rec" | "inherit" + ) } /// Return true if this string can be used as an identifier in Nix. |