m4b / scroll

Scroll - making scrolling through buffers fun since 2016
MIT License
151 stars 36 forks source link

Tracking issue for replacing unsafe code. #87

Open Frostie314159 opened 10 months ago

Frostie314159 commented 10 months ago

In the interest of exploring pure safe alternatives to unsafe functions, this issue tracks all uses and potential replacements. The unsafe portions are usually quite similar, so only one entry will be made per function.

Frostie314159 commented 10 months ago

Regarding the CStr::from_bytes_with_nul_unchecked, there exists a safe alternative: CStr::from_bytes_until_nul, which basically replaces all checks, we do already. Full disclosure, this function eventually calls the unchecked version internally, but IMO it's better to let core handle as much unsafe as possible, to profit from future optimizations.

m4b commented 3 weeks ago

sorry for late reply :) i agree with replacing CStr impl, if there is a safe, std alternative, that seems good to me. as for others, well, I would have to see proposals :)