From 642d32f688d735decccf2b844d113c436982f5e0 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Wed, 29 Jun 2022 17:28:31 -0400 Subject: [Rust API] Make more types convertible to BN types --- rust/src/string.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'rust/src/string.rs') diff --git a/rust/src/string.rs b/rust/src/string.rs index c1ca88d8..c4419b5e 100644 --- a/rust/src/string.rs +++ b/rust/src/string.rs @@ -14,7 +14,7 @@ //! String wrappers for core-owned strings and strings being passed to the core -use std::borrow::Borrow; +use std::borrow::{Borrow, Cow}; use std::ffi::{CStr, CString}; use std::fmt; use std::mem; @@ -231,3 +231,11 @@ unsafe impl BnStrCompatible for String { ret.into_bytes_with_nul() } } + +unsafe impl<'a> BnStrCompatible for &'a Cow<'a, str> { + type Result = &'a [u8]; + + fn as_bytes_with_nul(self) -> Self::Result { + self.as_ref().as_bytes() + } +} -- cgit v1.3.1