Add as_str_unchecked() to nsACString

This commit is contained in:
Xidorn Quan 2016-10-25 10:21:01 +11:00
parent 8bd7978980
commit eeada5ac51

View file

@ -144,6 +144,7 @@ use std::ptr;
use std::mem;
use std::fmt;
use std::cmp;
use std::str;
use std::u32;
//////////////////////////////////
@ -569,6 +570,10 @@ impl nsACString {
Gecko_AppendUTF16toCString(self as *mut _, other as *const _);
}
}
pub unsafe fn as_str_unchecked(&self) -> &str {
str::from_utf8_unchecked(self)
}
}
impl<'a> From<&'a str> for nsCString<'a> {