Skip to content

Commit

Permalink
chore: make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
mxndtaylor committed Nov 11, 2024
1 parent d72ad7f commit 150d5f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 3 additions & 2 deletions crates/toml_edit/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,12 @@ fn decorate_table(table: &mut Table) {
}
}

/// sort_by_key works because we add the position to _every_ item's key during parsing,
/// `Vec::sort_by_key` works because we add the position to _every_ item's key during parsing,
/// so keys without positions would be either:
/// 1. non-leaf keys (i.e. "foo" or "bar" in dotted key "foo.bar.baz")
/// 2. custom keys added to the doc without an explicit position
/// and in the case of (1), we'd never see it since we only look at the last
///
/// In the case of (1), we'd never see it since we only look at the last
/// key in a dotted-key. So, we can safely return a constant value for these cases.
///
/// To support the most intuitive behavior, we return the maximum usize, placing
Expand Down
6 changes: 1 addition & 5 deletions crates/toml_edit/tests/testsuite/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,6 @@ foo.baz.asdf = "b"
let foo_baz_asdf_v = foo_baz.remove("asdf").unwrap();
let foo_baz_asdf_k = Key::new("asdf").with_position(Some(0));

let foo_baz_asdf_k = foo_baz_asdf_k.with_position(Some(0));

foo_baz.insert_formatted(&foo_baz_asdf_k, foo_baz_asdf_v);
})
.produces_display(str![[r#"foo.bar = 1
Expand Down Expand Up @@ -1120,9 +1118,7 @@ foo.baz.asdf = "b"
let foo_baz = as_table!(foo_baz_v);

let foo_baz_asdf_v = foo_baz.remove("qwer").unwrap();
let foo_baz_asdf_k = Key::new("qwer").with_position(Some(0));

let foo_baz_asdf_k = foo_baz_asdf_k.clone().with_position(None);
let foo_baz_asdf_k = Key::new("qwer").with_position(None);

foo_baz.insert_formatted(&foo_baz_asdf_k, foo_baz_asdf_v);
})
Expand Down

0 comments on commit 150d5f8

Please sign in to comment.