wiggle: GuestPtr<[u8]> => GuestPtr<str> conversions

This commit is contained in:
Craig Pastro
2020-06-23 08:46:40 +09:00
parent f4e3e4efde
commit f9ef734698

View File

@@ -533,6 +533,14 @@ impl<'a> GuestPtr<'a, str> {
} }
} }
impl<'a> GuestPtr<'a, [u8]> {
/// Returns a raw pointer to the string represented by a `[u8]` without
/// validating whether each u8 is a utf-8 codepoint.
pub fn as_str_ptr(&self) -> GuestPtr<str> {
GuestPtr::new(self.mem, self.pointer)
}
}
impl<T: ?Sized + Pointee> Clone for GuestPtr<'_, T> { impl<T: ?Sized + Pointee> Clone for GuestPtr<'_, T> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
*self *self