rust-bakery / nom

Rust parser combinator framework
MIT License
9.38k stars 805 forks source link

Replace uses of `unsafe` with safe alternatives #1714

Closed nabilwadih closed 5 months ago

nabilwadih commented 10 months ago

Some of the usages of unsafe in the codebase can now be replaced with safe functions from the rust standard library. This PR updates those to remove the unsafe blocks

Verified that all of the tests are still passing.

Geal commented 5 months ago

these unsafe calls are there to avoid paying anohter bounds check (and for &str a is_char_boundary check) while code outside is already supposed to guarantee it

codspeed-hq[bot] commented 5 months ago

CodSpeed Performance Report

Merging #1714 will not alter performance

Comparing nabilwadih:nwadih/removeUnsafe (5ec2746) with main (cdd8baf)

Summary

✅ 24 untouched benchmarks

codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 62.01%. Comparing base (cdd8baf) to head (5ec2746).

Files Patch % Lines
src/traits.rs 80.00% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1714 +/- ## ========================================== - Coverage 62.01% 62.01% -0.01% ========================================== Files 24 24 Lines 2912 2917 +5 ========================================== + Hits 1806 1809 +3 - Misses 1106 1108 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.