Closed anforowicz closed 1 year ago
This all looks good. If someone can report a specific performance problem we could go back to directly calling the unsafe internal versions, but otherwise it's probably good policy to go through the safe interface when possible.
trait CheckedBitPattern
constraints the associatedtype Bits
as follows:Bits: AnyBitPattern
. This means thatchecked::try_from_bytes
doesn't need to callunsafe
internal::try_from_bytes
but can instead call the (safe) public APIcrate::try_from_bytes
(thanks to theAnyBitPattern
constraint). Similar reasoning can be applied to the other snippets modified by this PR. Being able to successfully compile the crate after this PR seems to confirm this reasoning.