mirror of https://github.com/kdl-org/kdl-rs.git
fix(fmt+clippy): sigh
This commit is contained in:
parent
fb9d725b06
commit
e47ca9c683
|
|
@ -1 +1 @@
|
||||||
msrv = "1.71.1"
|
msrv = "1.81"
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ words {
|
||||||
word_nodes.sort_by(sort_by_name);
|
word_nodes.sort_by(sort_by_name);
|
||||||
words_section.autoformat();
|
words_section.autoformat();
|
||||||
|
|
||||||
println!("{}", doc);
|
println!("{doc}");
|
||||||
|
|
||||||
// output:
|
// output:
|
||||||
// words {
|
// words {
|
||||||
|
|
|
||||||
|
|
@ -696,21 +696,21 @@ final;";
|
||||||
|
|
||||||
let bar = doc.get("bar").expect("expected a bar node");
|
let bar = doc.get("bar").expect("expected a bar node");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{}", bar),
|
format!("{bar}"),
|
||||||
"\n bar \"indented\" // trailing whitespace after this\t\n"
|
"\n bar \"indented\" // trailing whitespace after this\t\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
let a = doc.get("a").expect("expected a node");
|
let a = doc.get("a").expect("expected a node");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{}", a),
|
format!("{a}"),
|
||||||
"/*\nSome random comment\n */\n\na;".to_string()
|
"/*\nSome random comment\n */\n\na;".to_string()
|
||||||
);
|
);
|
||||||
|
|
||||||
let b = doc.get("b").expect("expected a node");
|
let b = doc.get("b").expect("expected a node");
|
||||||
assert_eq!(format!("{}", b), " b;".to_string());
|
assert_eq!(format!("{b}"), " b;".to_string());
|
||||||
|
|
||||||
// Round-tripping works.
|
// Round-tripping works.
|
||||||
assert_eq!(format!("{}", doc), src);
|
assert_eq!(format!("{doc}"), src);
|
||||||
|
|
||||||
// Programmatic manipulation works.
|
// Programmatic manipulation works.
|
||||||
let mut node: KdlNode = "new\n".parse()?;
|
let mut node: KdlNode = "new\n".parse()?;
|
||||||
|
|
@ -721,7 +721,7 @@ final;";
|
||||||
doc.nodes_mut().push(node);
|
doc.nodes_mut().push(node);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{}", doc),
|
format!("{doc}"),
|
||||||
format!("{}new \"blah\"=0xDEADbeef\n", src)
|
format!("{}new \"blah\"=0xDEADbeef\n", src)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -754,7 +754,7 @@ bar prop=value 1 2 #false #null {
|
||||||
}
|
}
|
||||||
baz
|
baz
|
||||||
"#,
|
"#,
|
||||||
format!("{}", doc)
|
format!("{doc}")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -633,10 +633,10 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn display() {
|
fn display() {
|
||||||
let entry = KdlEntry::new(KdlValue::Integer(42));
|
let entry = KdlEntry::new(KdlValue::Integer(42));
|
||||||
assert_eq!(format!("{}", entry), "42");
|
assert_eq!(format!("{entry}"), "42");
|
||||||
|
|
||||||
let entry = KdlEntry::new_prop("name", KdlValue::Integer(42));
|
let entry = KdlEntry::new_prop("name", KdlValue::Integer(42));
|
||||||
assert_eq!(format!("{}", entry), "name=42");
|
assert_eq!(format!("{entry}"), "name=42");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "v1")]
|
#[cfg(feature = "v1")]
|
||||||
|
|
|
||||||
|
|
@ -215,13 +215,13 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn formatting() {
|
fn formatting() {
|
||||||
let plain = KdlIdentifier::from("foo");
|
let plain = KdlIdentifier::from("foo");
|
||||||
assert_eq!(format!("{}", plain), "foo");
|
assert_eq!(format!("{plain}"), "foo");
|
||||||
|
|
||||||
let quoted = KdlIdentifier::from("foo\"bar");
|
let quoted = KdlIdentifier::from("foo\"bar");
|
||||||
assert_eq!(format!("{}", quoted), r#""foo\"bar""#);
|
assert_eq!(format!("{quoted}"), r#""foo\"bar""#);
|
||||||
|
|
||||||
let mut custom_repr = KdlIdentifier::from("foo");
|
let mut custom_repr = KdlIdentifier::from("foo");
|
||||||
custom_repr.set_repr(r#""foo/bar""#.to_string());
|
custom_repr.set_repr(r#""foo/bar""#.to_string());
|
||||||
assert_eq!(format!("{}", custom_repr), r#""foo/bar""#);
|
assert_eq!(format!("{custom_repr}"), r#""foo/bar""#);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -966,7 +966,10 @@ fn unambiguous_ident(input: &mut Input<'_>) -> PResult<()> {
|
||||||
cut_err(
|
cut_err(
|
||||||
repeat(1.., identifier_char)
|
repeat(1.., identifier_char)
|
||||||
.verify_map(|s: String| {
|
.verify_map(|s: String| {
|
||||||
if matches!(s.as_str(), "true" | "false" | "null" | "inf" | "-inf" | "nan") {
|
if matches!(
|
||||||
|
s.as_str(),
|
||||||
|
"true" | "false" | "null" | "inf" | "-inf" | "nan"
|
||||||
|
) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(s)
|
Some(s)
|
||||||
|
|
|
||||||
20
src/value.rs
20
src/value.rs
|
|
@ -38,9 +38,7 @@ impl PartialEq for KdlValue {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Self::String(l0), Self::String(r0)) => l0 == r0,
|
(Self::String(l0), Self::String(r0)) => l0 == r0,
|
||||||
(Self::Integer(l0), Self::Integer(r0)) => l0 == r0,
|
(Self::Integer(l0), Self::Integer(r0)) => l0 == r0,
|
||||||
(Self::Float(l0), Self::Float(r0)) => {
|
(Self::Float(l0), Self::Float(r0)) => normalize_float(l0) == normalize_float(r0),
|
||||||
normalize_float(l0) == normalize_float(r0)
|
|
||||||
}
|
|
||||||
(Self::Bool(l0), Self::Bool(r0)) => l0 == r0,
|
(Self::Bool(l0), Self::Bool(r0)) => l0 == r0,
|
||||||
_ => core::mem::discriminant(self) == core::mem::discriminant(other),
|
_ => core::mem::discriminant(self) == core::mem::discriminant(other),
|
||||||
}
|
}
|
||||||
|
|
@ -161,11 +159,7 @@ pub(crate) fn is_plain_ident(ident: &str) -> bool {
|
||||||
.find(crate::v2_parser::is_disallowed_ident_char)
|
.find(crate::v2_parser::is_disallowed_ident_char)
|
||||||
.is_none()
|
.is_none()
|
||||||
&& ident_bytes.first().map(|c| c.is_ascii_digit()) != Some(true)
|
&& ident_bytes.first().map(|c| c.is_ascii_digit()) != Some(true)
|
||||||
&& !(ident
|
&& !(ident.chars().next().map(|c| matches!(c, '.' | '-' | '+')) == Some(true)
|
||||||
.chars()
|
|
||||||
.next()
|
|
||||||
.map(|c| matches!(c, '.' | '-' | '+'))
|
|
||||||
== Some(true)
|
|
||||||
&& ident_bytes.get(1).map(|c| c.is_ascii_digit()) == Some(true))
|
&& ident_bytes.get(1).map(|c| c.is_ascii_digit()) == Some(true))
|
||||||
&& ident != "inf"
|
&& ident != "inf"
|
||||||
&& ident != "-inf"
|
&& ident != "-inf"
|
||||||
|
|
@ -272,18 +266,18 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn formatting() {
|
fn formatting() {
|
||||||
let string = KdlValue::String("foo\n".into());
|
let string = KdlValue::String("foo\n".into());
|
||||||
assert_eq!(format!("{}", string), r#""foo\n""#);
|
assert_eq!(format!("{string}"), r#""foo\n""#);
|
||||||
|
|
||||||
let integer = KdlValue::Integer(1234567890);
|
let integer = KdlValue::Integer(1234567890);
|
||||||
assert_eq!(format!("{}", integer), "1234567890");
|
assert_eq!(format!("{integer}"), "1234567890");
|
||||||
|
|
||||||
let float = KdlValue::Float(1234567890.12345);
|
let float = KdlValue::Float(1234567890.12345);
|
||||||
assert_eq!(format!("{}", float), "1234567890.12345");
|
assert_eq!(format!("{float}"), "1234567890.12345");
|
||||||
|
|
||||||
let boolean = KdlValue::Bool(true);
|
let boolean = KdlValue::Bool(true);
|
||||||
assert_eq!(format!("{}", boolean), "#true");
|
assert_eq!(format!("{boolean}"), "#true");
|
||||||
|
|
||||||
let null = KdlValue::Null;
|
let null = KdlValue::Null;
|
||||||
assert_eq!(format!("{}", null), "#null");
|
assert_eq!(format!("{null}"), "#null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue