Skip to content

Commit 1d67d0f

Browse files
committed
Use remove to get first key
Signed-off-by: hi-rustin <[email protected]>
1 parent ea5ade3 commit 1d67d0f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/cargo/ops/cargo_add/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,10 @@ pub fn add(workspace: &Workspace<'_>, options: &AddOptions<'_>) -> CargoResult<(
9999
.map(TomlItem::as_table)
100100
.map_or(true, |table_option| {
101101
table_option.map_or(true, |table| {
102-
is_sorted(
103-
table
104-
.get_values()
105-
.iter()
106-
.map(|(key, _)| key.first().unwrap().to_string()),
107-
)
102+
is_sorted(table.get_values().iter_mut().map(|(key, _)| {
103+
// get_values key paths always have at least one key.
104+
key.remove(0)
105+
}))
108106
})
109107
});
110108
for dep in deps {

0 commit comments

Comments
 (0)