adds readme; tweak code example

This commit is contained in:
Jonathan Strong 2022-10-05 12:52:31 -04:00
parent 0d02e98749
commit 5dbfa46a34
3 changed files with 21 additions and 2 deletions

View File

@ -1,12 +1,13 @@
[package]
name = "const-crc32"
version = "1.0.0"
version = "1.0.1"
edition = "2021"
authors = ["Jonathan Strong <jstrong@shipyard.rs>"]
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"

17
README.md Normal file
View File

@ -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.

View File

@ -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