Skip to content

Commit

Permalink
Merge pull request #1 from ZcashFoundation/no-std
Browse files Browse the repository at this point in the history
add no_std support
  • Loading branch information
natalieesk authored Feb 16, 2024
2 parents 9446cf6 + a842a61 commit 3b5b17e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "const-crc32"
version = "1.3.0"
name = "const-crc32-nostd"
version = "1.3.1"
edition = "2021"
authors = ["Jonathan Strong <[email protected]>"]
license = "MIT"
description = "A `const fn` implementation of crc32 checksum algorithm"
repository = "https://git.shipyard.rs/jstrong/const-crc32"
keywords = ["checksum", "crc", "crc32", "const"]
keywords = ["checksum", "crc", "crc32", "const", "no_std"]
readme = "README.md"

[dev-dependencies]
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
//! # Examples
//!
//! ```
//! use const_crc32_nostd as const_crc32;
//! 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);
//! ```
#![no_std]

/// used to generate up a [u32; 256] lookup table in `crc32`. this computes
/// the table on demand for a given "index" `i`
Expand Down Expand Up @@ -57,6 +59,8 @@ pub const fn crc32(buf: &[u8]) -> u32 {
/// Calculating the checksum from several parts of a larger input:
///
/// ```
/// use const_crc32_nostd as const_crc32;
///
/// const BYTES: &[u8] = "The quick brown fox jumps over the lazy dog".as_bytes();
///
/// let mut cksum = 0u32;
Expand All @@ -72,6 +76,8 @@ pub const fn crc32(buf: &[u8]) -> u32 {
/// on what kind of data the bytes represent:
///
/// ```
/// use const_crc32_nostd as const_crc32;
///
/// const THING_ONE_SEED: u32 = 0xbaaaaaad_u32;
/// const THING_TWO_SEED: u32 = 0x2bad2bad_u32;
///
Expand Down

0 comments on commit 3b5b17e

Please sign in to comment.