Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ generify RawChunk::from_data #344

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl RawChunk {
/// ```
/// use libpna::{Chunk, ChunkType, RawChunk};
///
/// let data = vec![0xAA, 0xBB, 0xCC, 0xDD];
/// let data = [0xAA, 0xBB, 0xCC, 0xDD];
/// let chunk = RawChunk::from_data(ChunkType::FDAT, data);
///
/// assert_eq!(chunk.length(), 4);
Expand All @@ -51,7 +51,8 @@ impl RawChunk {
/// assert_eq!(chunk.crc(), 1207118608);
/// ```
#[inline]
pub fn from_data(ty: ChunkType, data: Vec<u8>) -> Self {
pub fn from_data<T: Into<Vec<u8>>>(ty: ChunkType, data: T) -> Self {
let data = data.into();
let chunk = (ty, &data[..]);
Self {
length: chunk.length(),
Expand Down