From 009ec28ddf93edd36b54fb597a112691d4dc1371 Mon Sep 17 00:00:00 2001 From: Carl Sverre <82591+carlsverre@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:39:05 -0800 Subject: [PATCH 1/3] Support conversion from &String to Slice. Needed for a test in fjall to pass related to https://github.com/fjall-rs/fjall/issues/99 --- src/slice.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/slice.rs b/src/slice.rs index 2a0af28..e466cca 100644 --- a/src/slice.rs +++ b/src/slice.rs @@ -33,6 +33,12 @@ impl From<&str> for Slice { } } +impl From<&String> for Slice { + fn from(value: &String) -> Self { + Self::from(value.as_str()) + } +} + impl From> for Slice { fn from(value: Arc) -> Self { Self::from(&*value) From 061ff872b653738e866284abf164c7596095a657 Mon Sep 17 00:00:00 2001 From: Carl Sverre <82591+carlsverre@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:31:07 -0800 Subject: [PATCH 2/3] add conversion from &Vec --- src/slice.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/slice.rs b/src/slice.rs index e466cca..d38b454 100644 --- a/src/slice.rs +++ b/src/slice.rs @@ -27,6 +27,12 @@ impl From<&[u8]> for Slice { } } +impl From<&Vec> for Slice { + fn from(value: &Vec) -> Self { + Self::from(value.as_slice()) + } +} + impl From<&str> for Slice { fn from(value: &str) -> Self { Self::from(value.as_bytes()) From f22eaf4d0b83b9a62e64e52ec768425870e241bc Mon Sep 17 00:00:00 2001 From: Carl Sverre <82591+carlsverre@users.noreply.github.com> Date: Tue, 3 Dec 2024 16:37:36 -0800 Subject: [PATCH 3/3] added conversion from array ref to slice --- src/slice.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/slice.rs b/src/slice.rs index d38b454..5d2ed09 100644 --- a/src/slice.rs +++ b/src/slice.rs @@ -57,6 +57,12 @@ impl From<[u8; N]> for Slice { } } +impl From<&[u8; N]> for Slice { + fn from(value: &[u8; N]) -> Self { + Self::from(value.as_slice()) + } +} + impl FromIterator for Slice { fn from_iter(iter: T) -> Self where