Files
Brent Westbrook 244668339a Adopt new APIs from Rust 1.98 (#30419)
Summary
--

- The first commit uses [strip_circumfix] to remove paired delimiters in
one call.
- The second commit uses [map_or_default] to combine many `map` and
`unwrap_or_default` calls.
- The third commit uses [bool::ok_or] to turn boolean checks into
`Result<(), E>` values.
- The fourth commit uses [str::substr_range] to get the byte range of a
TODO directive directly from the comment.

The last commit is slightly more involved than the others, as Codex
found a panic in the old code if
a `HACK` TODO comment used the Kelvin sign as its `K` and added a test
showing that `substr_range`
helped to fix it. That seems absurdly niche, but the new code is simpler
anyway.

There's also a new [format_into] API for formatting integers into a
`NumBuffer` and bypassing some
`Display` overhead. We could use this in the `UP031` fix, but it makes
the code a bit more
complicated and seemed worth trying and benchmarking separately to see
if it's worth the trouble.

[strip_circumfix]:
https://doc.rust-lang.org/stable/std/primitive.str.html#method.strip_circumfix
[map_or_default]:
https://doc.rust-lang.org/stable/std/option/enum.Option.html#method.map_or_default
[bool::ok_or]:
https://doc.rust-lang.org/stable/std/primitive.bool.html#method.ok_or
[str::substr_range]:
https://doc.rust-lang.org/stable/std/primitive.str.html#method.substr_range
[format_into]:
https://doc.rust-lang.org/stable/core/primitive.usize.html#method.format_into
2026-11-16 10:04:15 -05:00
..
2026-07-14 12:13:23 -04:00