mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Bug 1330824 - Add truncate for nsAString and nsACString. r=mystor
MozReview-Commit-ID: 2ND5ra3buxI
This commit is contained in:
parent
b914d41d52
commit
ce59a7e9ee
1 changed files with 14 additions and 0 deletions
|
@ -574,6 +574,12 @@ impl nsACString {
|
|||
pub unsafe fn as_str_unchecked(&self) -> &str {
|
||||
str::from_utf8_unchecked(self)
|
||||
}
|
||||
|
||||
pub fn truncate(&mut self) {
|
||||
unsafe {
|
||||
Gecko_TruncateCString(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for nsCString<'a> {
|
||||
|
@ -674,6 +680,12 @@ impl nsAString {
|
|||
Gecko_AppendUTF8toString(self as *mut _, other as *const _);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn truncate(&mut self) {
|
||||
unsafe {
|
||||
Gecko_TruncateString(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: The From impl for a string slice for nsString produces a <'static>
|
||||
|
@ -727,10 +739,12 @@ extern "C" {
|
|||
fn Gecko_FinalizeCString(this: *mut nsACString);
|
||||
fn Gecko_AssignCString(this: *mut nsACString, other: *const nsACString);
|
||||
fn Gecko_AppendCString(this: *mut nsACString, other: *const nsACString);
|
||||
fn Gecko_TruncateCString(this: *mut nsACString);
|
||||
|
||||
fn Gecko_FinalizeString(this: *mut nsAString);
|
||||
fn Gecko_AssignString(this: *mut nsAString, other: *const nsAString);
|
||||
fn Gecko_AppendString(this: *mut nsAString, other: *const nsAString);
|
||||
fn Gecko_TruncateString(this: *mut nsAString);
|
||||
|
||||
// Gecko implementation in nsReadableUtils.cpp
|
||||
fn Gecko_AppendUTF16toCString(this: *mut nsACString, other: *const nsAString);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue