Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Update slice to array conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
so-schen committed Dec 10, 2023
1 parent 99067d9 commit 0a73a36
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde_bytes_ng"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
categories = ["encoding", "no-std", "no-std::no-alloc"]
description = "Optimized handling of `[u8; N]`, `&[u8]` and `Vec<u8>` for Serde"
Expand Down
4 changes: 1 addition & 3 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ impl<'de, const N: usize> Deserialize<'de> for [u8; N] {
return Err(E::invalid_length(v.len(), &self));
}

let mut arr = [0; N];
arr.copy_from_slice(v);
Ok(arr)
Ok(v.try_into().unwrap())
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
Expand Down

0 comments on commit 0a73a36

Please sign in to comment.