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);
|
||||
words_section.autoformat();
|
||||
|
||||
println!("{}", doc);
|
||||
println!("{doc}");
|
||||
|
||||
// output:
|
||||
// words {
|
||||
|
|
|
|||
|
|
@ -696,21 +696,21 @@ final;";
|
|||
|
||||
let bar = doc.get("bar").expect("expected a bar node");
|
||||
assert_eq!(
|
||||
format!("{}", bar),
|
||||
format!("{bar}"),
|
||||
"\n bar \"indented\" // trailing whitespace after this\t\n"
|
||||
);
|
||||
|
||||
let a = doc.get("a").expect("expected a node");
|
||||
assert_eq!(
|
||||
format!("{}", a),
|
||||
format!("{a}"),
|
||||
"/*\nSome random comment\n */\n\na;".to_string()
|
||||
);
|
||||
|
||||
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.
|
||||
assert_eq!(format!("{}", doc), src);
|
||||
assert_eq!(format!("{doc}"), src);
|
||||
|
||||
// Programmatic manipulation works.
|
||||
let mut node: KdlNode = "new\n".parse()?;
|
||||
|
|
@ -721,7 +721,7 @@ final;";
|
|||
doc.nodes_mut().push(node);
|
||||
|
||||
assert_eq!(
|
||||
format!("{}", doc),
|
||||
format!("{doc}"),
|
||||
format!("{}new \"blah\"=0xDEADbeef\n", src)
|
||||
);
|
||||
|
||||
|
|
@ -754,7 +754,7 @@ bar prop=value 1 2 #false #null {
|
|||
}
|
||||
baz
|
||||
"#,
|
||||
format!("{}", doc)
|
||||
format!("{doc}")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -633,10 +633,10 @@ mod test {
|
|||
#[test]
|
||||
fn display() {
|
||||
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));
|
||||
assert_eq!(format!("{}", entry), "name=42");
|
||||
assert_eq!(format!("{entry}"), "name=42");
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
|
|
|
|||
|
|
@ -215,13 +215,13 @@ mod test {
|
|||
#[test]
|
||||
fn formatting() {
|
||||
let plain = KdlIdentifier::from("foo");
|
||||
assert_eq!(format!("{}", plain), "foo");
|
||||
assert_eq!(format!("{plain}"), "foo");
|
||||
|
||||
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");
|
||||
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(
|
||||
repeat(1.., identifier_char)
|
||||
.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
|
||||
} else {
|
||||
Some(s)
|
||||
|
|
|
|||
20
src/value.rs
20
src/value.rs
|
|
@ -38,9 +38,7 @@ impl PartialEq for KdlValue {
|
|||
match (self, other) {
|
||||
(Self::String(l0), Self::String(r0)) => l0 == r0,
|
||||
(Self::Integer(l0), Self::Integer(r0)) => l0 == r0,
|
||||
(Self::Float(l0), Self::Float(r0)) => {
|
||||
normalize_float(l0) == normalize_float(r0)
|
||||
}
|
||||
(Self::Float(l0), Self::Float(r0)) => normalize_float(l0) == normalize_float(r0),
|
||||
(Self::Bool(l0), Self::Bool(r0)) => l0 == r0,
|
||||
_ => 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)
|
||||
.is_none()
|
||||
&& ident_bytes.first().map(|c| c.is_ascii_digit()) != Some(true)
|
||||
&& !(ident
|
||||
.chars()
|
||||
.next()
|
||||
.map(|c| matches!(c, '.' | '-' | '+'))
|
||||
== Some(true)
|
||||
&& !(ident.chars().next().map(|c| matches!(c, '.' | '-' | '+')) == Some(true)
|
||||
&& ident_bytes.get(1).map(|c| c.is_ascii_digit()) == Some(true))
|
||||
&& ident != "inf"
|
||||
&& ident != "-inf"
|
||||
|
|
@ -272,18 +266,18 @@ mod test {
|
|||
#[test]
|
||||
fn formatting() {
|
||||
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);
|
||||
assert_eq!(format!("{}", integer), "1234567890");
|
||||
assert_eq!(format!("{integer}"), "1234567890");
|
||||
|
||||
let float = KdlValue::Float(1234567890.12345);
|
||||
assert_eq!(format!("{}", float), "1234567890.12345");
|
||||
assert_eq!(format!("{float}"), "1234567890.12345");
|
||||
|
||||
let boolean = KdlValue::Bool(true);
|
||||
assert_eq!(format!("{}", boolean), "#true");
|
||||
assert_eq!(format!("{boolean}"), "#true");
|
||||
|
||||
let null = KdlValue::Null;
|
||||
assert_eq!(format!("{}", null), "#null");
|
||||
assert_eq!(format!("{null}"), "#null");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue