refactor(tvix/serde): cargo clippy
Change-Id: I3c86225040a04c9cb5702b226b4a5008ae219c42 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9093 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
This commit is contained in:
parent
9cb38c5ba5
commit
600d4eec77
3 changed files with 13 additions and 14 deletions
|
@ -304,8 +304,7 @@ impl<'de> de::Deserializer<'de> for NixDeserializer {
|
||||||
V: de::Visitor<'de>,
|
V: de::Visitor<'de>,
|
||||||
{
|
{
|
||||||
if let Value::List(list) = self.value {
|
if let Value::List(list) = self.value {
|
||||||
let mut seq =
|
let mut seq = SeqDeserializer::new(list.into_iter().map(NixDeserializer::new));
|
||||||
SeqDeserializer::new(list.into_iter().map(|value| NixDeserializer::new(value)));
|
|
||||||
let result = visitor.visit_seq(&mut seq)?;
|
let result = visitor.visit_seq(&mut seq)?;
|
||||||
seq.end()?;
|
seq.end()?;
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
|
|
|
@ -161,24 +161,24 @@ fn deserialize_enum_all() {
|
||||||
#[derive(Debug, Deserialize, PartialEq)]
|
#[derive(Debug, Deserialize, PartialEq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
enum TestEnum {
|
enum TestEnum {
|
||||||
UnitVariant,
|
Unit,
|
||||||
TupleVariant(String, String),
|
Tuple(String, String),
|
||||||
StructVariant { name: String, age: usize },
|
Struct { name: String, age: usize },
|
||||||
}
|
}
|
||||||
|
|
||||||
let result: Vec<TestEnum> = from_str(
|
let result: Vec<TestEnum> = from_str(
|
||||||
r#"
|
r#"
|
||||||
let
|
let
|
||||||
mkTuple = country: drink: { tuple_variant = [ country drink ]; };
|
mkTuple = country: drink: { tuple = [ country drink ]; };
|
||||||
in
|
in
|
||||||
[
|
[
|
||||||
(mkTuple "UK" "cask ale")
|
(mkTuple "UK" "cask ale")
|
||||||
|
|
||||||
"unit_variant"
|
"unit"
|
||||||
|
|
||||||
{
|
{
|
||||||
struct_variant.name = "Slartibartfast";
|
struct.name = "Slartibartfast";
|
||||||
struct_variant.age = 42;
|
struct.age = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
(mkTuple "Russia" "квас")
|
(mkTuple "Russia" "квас")
|
||||||
|
@ -188,13 +188,13 @@ fn deserialize_enum_all() {
|
||||||
.expect("should deserialize");
|
.expect("should deserialize");
|
||||||
|
|
||||||
let expected = vec![
|
let expected = vec![
|
||||||
TestEnum::TupleVariant("UK".into(), "cask ale".into()),
|
TestEnum::Tuple("UK".into(), "cask ale".into()),
|
||||||
TestEnum::UnitVariant,
|
TestEnum::Unit,
|
||||||
TestEnum::StructVariant {
|
TestEnum::Struct {
|
||||||
name: "Slartibartfast".into(),
|
name: "Slartibartfast".into(),
|
||||||
age: 42,
|
age: 42,
|
||||||
},
|
},
|
||||||
TestEnum::TupleVariant("Russia".into(), "квас".into()),
|
TestEnum::Tuple("Russia".into(), "квас".into()),
|
||||||
];
|
];
|
||||||
|
|
||||||
assert_eq!(result, expected);
|
assert_eq!(result, expected);
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl Display for Error {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
for err in errors {
|
for err in errors {
|
||||||
writeln!(f, "{}", err.fancy_format_str(&source))?;
|
writeln!(f, "{}", err.fancy_format_str(source))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue