Use raw::Slice where it makes sense.

This commit is contained in:
Ms2ger 2015-04-07 17:54:36 +02:00
parent b5d41aa8a5
commit cba3b6806e

View file

@ -36,6 +36,7 @@ use std::boxed;
use std::collections::HashMap;
use std::mem;
use std::ptr;
use std::raw;
pub trait CefWrap<CObject> {
fn to_c(rust_object: Self) -> CObject;
@ -196,8 +197,10 @@ impl<'a> CefWrap<*const cef_string_t> for &'a [u16] {
}
}
unsafe fn to_rust(cef_string: *const cef_string_t) -> &'a [u16] {
let (ptr, len): (*mut c_ushort, uint) = ((*cef_string).str, (*cef_string).length as uint);
mem::transmute((ptr, len))
mem::transmute(raw::Slice {
data: (*cef_string).str,
len: (*cef_string).length as usize,
})
}
}