Closed voidc closed 2 years ago
For reference, the crc32fast
crate provides a new_with_initial
function.
Would it be possible to add some test cases with the expected checksums generated by another crc impl? I'm not sure if the way we handle reflection of custom init is considered "correct".
I'd say the way it is handled now is conceptually correct since the custom init value is treated in the same way as Algorithm::init
which is IMO what users would expect to happen. If you want, I can add a comment to the digest_with_initial
methods documenting this behavior. As for tests, I'm not sure what would be a good alternative impl for comparison.
I'd say the way it is handled now is conceptually correct since the custom init value is treated in the same way as
Algorithm::init
which is IMO what users would expect to happen. If you want, I can add a comment to thedigest_with_initial
methods documenting this behavior. As for tests, I'm not sure what would be a good alternative impl for comparison.
A comment would be enough IMO, and then we can merge.
Thanks for merging! Would it be possible to release a new version including this change on crates.io?
I'll try to cut a minor release (v2.2.0) by tomorrow. There are some breaking changes that I either need to patch or exclude.
It may sometimes be useful to compute CRC values with an initial value different from the one specified by the used algorithm. In this case, users currently have to create a new
Algorithm
for each initial value. This is particularly problematic if the initial values are not statically known, sinceCrc::new
takes a static reference to an algorithm (see also #68). With the small change proposed in this PR, an initial value may optionally be supplied when creating aDigest
.