mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Added in-place mutation to DOMString.
The methods which are currently implemented are the ones on String that are currently being used: string.push_str(...), string.clear() and string.extend(...). We may want to revisit this API.
This commit is contained in:
parent
034769f280
commit
5db67b5981
5 changed files with 23 additions and 5 deletions
|
@ -32,6 +32,13 @@ impl DOMString {
|
|||
pub fn new() -> DOMString {
|
||||
DOMString(String::new())
|
||||
}
|
||||
// FIXME(ajeffrey): implement more of the String methods on DOMString?
|
||||
pub fn push_str(&mut self, string: &str) {
|
||||
self.0.push_str(string)
|
||||
}
|
||||
pub fn clear(&mut self) {
|
||||
self.0.clear()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for DOMString {
|
||||
|
@ -181,6 +188,12 @@ impl FromJSValConvertible for DOMString {
|
|||
}
|
||||
}
|
||||
|
||||
impl Extend<char> for DOMString {
|
||||
fn extend<I>(&mut self, iterable: I) where I: IntoIterator<Item=char> {
|
||||
self.0.extend(iterable)
|
||||
}
|
||||
}
|
||||
|
||||
pub type StaticCharVec = &'static [char];
|
||||
pub type StaticStringVec = &'static [&'static str];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue