diff options
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() + } +} |
