Browse Source

adds readme; tweak code example

pull/1/head v1.0.1
Jonathan Strong 2 years ago
parent
commit
5dbfa46a34
  1. 3
      Cargo.toml
  2. 17
      README.md
  3. 3
      src/lib.rs

3
Cargo.toml

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

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

3
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

Loading…
Cancel
Save