5 trait Structure<E>: Sized where E: Encoding {
6 type RefTarget: ?Sized;
8 unsafe fn borrow_from_ffi_ptr<'a>(ptr: Self::FfiPtr) -> Option<&'a Self::RefTarget>;
13 impl<E> Structure<E> for Slice where E: Encoding {
14 type RefTarget = [E::Unit];
15 type FfiPtr = (*const E::FfiUnit, usize);
16 unsafe fn borrow_from_ffi_ptr<'a>(_ptr: Self::FfiPtr) -> Option<&'a Self::RefTarget> {
30 impl Encoding for Utf16 {
31 type Unit = Utf16Unit;
35 struct Utf16Unit(pub u16);
37 impl Unit for Utf16Unit {}
40 _data: <Slice as Structure<Utf16>>::RefTarget,
44 pub unsafe fn from_ptr<'a>(ptr: <Slice as Structure<Utf16>>::FfiPtr)
46 std::mem::transmute::<Option<&[<Utf16 as Encoding>::Unit]>, _>(
47 <Slice as Structure<Utf16>>::borrow_from_ffi_ptr(ptr))
52 const TEXT_U16: &'static [u16] = &[];
53 let _ = unsafe { SUtf16Str::from_ptr((TEXT_U16.as_ptr(), TEXT_U16.len())).unwrap() };