From 2320068258325a5d214914cd9b0f3bd6355db4a9 Mon Sep 17 00:00:00 2001 From: Dmytro Kozhevin Date: Mon, 7 Oct 2024 20:07:48 -0400 Subject: [PATCH] Add &Bytes->Val conversions. (#1362) ### What Add &Bytes->Val conversions. ### Why These were missing. ### Known limitations N/A --- soroban-sdk/src/bytes.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/soroban-sdk/src/bytes.rs b/soroban-sdk/src/bytes.rs index af4094a25..2e427f1ed 100644 --- a/soroban-sdk/src/bytes.rs +++ b/soroban-sdk/src/bytes.rs @@ -299,6 +299,14 @@ impl TryFromVal for Val { } } +impl TryFromVal for Val { + type Error = ConversionError; + + fn try_from_val(_env: &Env, v: &&Bytes) -> Result { + Ok(v.to_val()) + } +} + impl From for Val { #[inline(always)] fn from(v: Bytes) -> Self { @@ -1013,6 +1021,14 @@ impl TryFromVal> for Val { } } +impl TryFromVal> for Val { + type Error = ConversionError; + + fn try_from_val(_env: &Env, v: &&BytesN) -> Result { + Ok(v.to_val()) + } +} + impl TryFrom for BytesN { type Error = ConversionError;