Skip to content

Commit

Permalink
Implement Clone for Crc
Browse files Browse the repository at this point in the history
Signed-off-by: Akhil Velagapudi <4@4khil.com>
  • Loading branch information
akhilles committed Apr 8, 2024
1 parent 0058d45 commit bb9e851
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub trait Implementation: private::Sealed {

/// A table-based implementation of the CRC algorithm, with `L` lanes.
/// The number of entries in the lookup table is `L * 256`.
#[derive(Copy, Clone)]
pub struct Table<const L: usize> {}

/// An implementation of the CRC algorithm with no lookup table.
Expand All @@ -64,6 +65,7 @@ mod private {
}

/// Crc instance with a specific width, algorithm, and implementation.
#[derive(Clone)]
pub struct Crc<W: Width, I: Implementation = DefaultImpl> {
pub algorithm: &'static Algorithm<W>,
data: I::Data<W>,
Expand All @@ -74,3 +76,14 @@ pub struct Digest<'a, W: Width, I: Implementation = DefaultImpl> {
crc: &'a Crc<W, I>,
value: W,
}

#[cfg(test)]
mod test {
use super::{Crc, CRC_32_ISCSI};

#[test]
fn test_clone() {
const CRC: Crc<u32> = Crc::<u32>::new(&CRC_32_ISCSI);
let _crc = CRC.clone();
}
}

0 comments on commit bb9e851

Please sign in to comment.