diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-06-29 17:28:31 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-09-29 21:02:20 -0400 |
| commit | 642d32f688d735decccf2b844d113c436982f5e0 (patch) | |
| tree | 0148b8474bd154345c121c623b2fa23159e0c755 /rust/src/string.rs | |
| parent | 207925956bb8ca0174d40523fda70bfb5bc7bd38 (diff) | |
[Rust API] Make more types convertible to BN types
Diffstat (limited to 'rust/src/string.rs')
| -rw-r--r-- | rust/src/string.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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() + } +} |
