mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Use slice::from_raw_parts to convert cef_string_t to &[u16].
This commit is contained in:
parent
26964ff087
commit
49e0442459
1 changed files with 2 additions and 5 deletions
|
@ -38,7 +38,7 @@ use std::boxed;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::raw;
|
use std::slice;
|
||||||
|
|
||||||
pub trait CefWrap<CObject> {
|
pub trait CefWrap<CObject> {
|
||||||
fn to_c(rust_object: Self) -> CObject;
|
fn to_c(rust_object: Self) -> CObject;
|
||||||
|
@ -209,10 +209,7 @@ impl<'a> CefWrap<*const cef_string_t> for &'a [u16] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsafe fn to_rust(cef_string: *const cef_string_t) -> &'a [u16] {
|
unsafe fn to_rust(cef_string: *const cef_string_t) -> &'a [u16] {
|
||||||
mem::transmute(raw::Slice {
|
slice::from_raw_parts((*cef_string).str, (*cef_string).length as usize)
|
||||||
data: (*cef_string).str,
|
|
||||||
len: (*cef_string).length as usize,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue