diff --git a/Cargo.toml b/Cargo.toml index de0fb64..e6038ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,13 @@ [package] name = "const-crc32" -version = "1.0.0" +version = "1.0.1" edition = "2021" authors = ["Jonathan Strong "] license = "MIT" description = "A `const fn` implementation of crc32 checksum algorithm" repository = "https://git.shipyard.rs/jstrong/const-crc32" keywords = ["checksum", "crc", "crc32", "const"] +readme = "README.md" [dev-dependencies] crc32fast = "1.2" diff --git a/README.md b/README.md new file mode 100644 index 0000000..cec5f16 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# const-crc32 + +A `const fn` crc32 checksum implementation. + +## Examples + +```rust +const BYTES: &[u8] = "The quick brown fox jumps over the lazy dog".as_bytes(); +const CKSUM: u32 = const_crc32::crc32(BYTES); +assert_eq!(CKSUM, 0x414fa339_u32); +``` + +## Usage + +This is a naive implementation that should be expected to have poor performance +if used on dynamic data at runtime. Usage should generally be restricted to declaring +`const` variables based on `static` or `const` data available at build time. diff --git a/src/lib.rs b/src/lib.rs index 4a9a992..9ac0678 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,8 @@ //! //! ``` //! const BYTES: &[u8] = "The quick brown fox jumps over the lazy dog".as_bytes(); -//! assert_eq!(const_crc32::crc32(BYTES), 0x414fa339_u32); +//! const CKSUM: u32 = const_crc32::crc32(BYTES); +//! assert_eq!(CKSUM, 0x414fa339_u32); //! ``` /// typically crc32 implementations set up a [u32; 256] lookup table. this computes