mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Implement clone_content method
This commit is contained in:
parent
e0b834033d
commit
c05baa2327
3 changed files with 93 additions and 15 deletions
|
@ -919,3 +919,16 @@ impl<T> Rect<T> where T: GeckoStyleCoordConvertible {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert to String from given chars pointer.
|
||||
pub unsafe fn string_from_chars_pointer(p: *const u16) -> String {
|
||||
use std::slice;
|
||||
let mut length = 0;
|
||||
let mut iter = p;
|
||||
while *iter != 0 {
|
||||
length += 1;
|
||||
iter = iter.offset(1);
|
||||
}
|
||||
let char_vec = slice::from_raw_parts(p, length as usize);
|
||||
String::from_utf16_lossy(char_vec)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue