Skip to content

Commit ae2a811

Browse files
committed
Auto merge of #1305 - ssomers:map_first_last_vs_miri, r=RalfJung
Replace last_entry with last_key_value Wondering why `last_entry` was introduced (in #1156) while the alternative is shorter and seems clearer to me. Also, as the perpetrator of map_first_last, I now think that `first_entry`/`last_entry` are silly methods because they're supposed to be constant time (as opposed to `entry`), so there's no money to be made by doing multiple things with the entry.
2 parents b1f0537 + e7fafa1 commit ae2a811

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/shims/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl FileHandler {
5656
let new_fd = candidate_new_fd.unwrap_or_else(|| {
5757
// find_map ran out of BTreeMap entries before finding a free fd, use one plus the
5858
// maximum fd in the map
59-
self.handles.last_entry().map(|entry| entry.key().checked_add(1).unwrap()).unwrap_or(min_fd)
59+
self.handles.last_key_value().map(|(fd, _)| fd.checked_add(1).unwrap()).unwrap_or(min_fd)
6060
});
6161

6262
self.handles.insert(new_fd, file_handle).unwrap_none();

0 commit comments

Comments
 (0)