Skip to content

Commit

Permalink
Add &Bytes->Val conversions. (#1362)
Browse files Browse the repository at this point in the history
### What

Add &Bytes->Val conversions.

### Why

These were missing.

### Known limitations

N/A
  • Loading branch information
dmkozh authored Oct 8, 2024
1 parent f0e653e commit 2320068
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions soroban-sdk/src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ impl TryFromVal<Env, Bytes> for Val {
}
}

impl TryFromVal<Env, &Bytes> for Val {
type Error = ConversionError;

fn try_from_val(_env: &Env, v: &&Bytes) -> Result<Self, Self::Error> {
Ok(v.to_val())
}
}

impl From<Bytes> for Val {
#[inline(always)]
fn from(v: Bytes) -> Self {
Expand Down Expand Up @@ -1013,6 +1021,14 @@ impl<const N: usize> TryFromVal<Env, BytesN<N>> for Val {
}
}

impl<const N: usize> TryFromVal<Env, &BytesN<N>> for Val {
type Error = ConversionError;

fn try_from_val(_env: &Env, v: &&BytesN<N>) -> Result<Self, Self::Error> {
Ok(v.to_val())
}
}

impl<const N: usize> TryFrom<Bytes> for BytesN<N> {
type Error = ConversionError;

Expand Down

0 comments on commit 2320068

Please sign in to comment.