mrhooray / crc-rs

Rust implementation of CRC(16, 32, 64) with support of various standards
Apache License 2.0
187 stars 49 forks source link

Derive Clone for Crc #103

Closed nrempel closed 1 year ago

nrempel commented 1 year ago

Hi there,

Would you consider deriving Clone for Crc? This would make the crate more convenient to use.

Thanks!

akhilles commented 1 year ago

Should be fine, but please be aware that cloning Crc also clones the table, which can be on the order of 16 KiB for 32-bit crc. So, I wouldn't recommend it.

nrempel commented 1 year ago

Hm, yeah that's not ideal. I'll look at avoiding the clone here. Thanks.

akhilles commented 1 year ago

@nrempel you could define a const &'static Crc value and then clone that. e.g: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=4d36d676a9093586048b76018504a1df.

nrempel commented 1 year ago

Thanks @akhilles, I ended up using once_cell::sync::Lazy which works well for my case.