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:
Alan Jeffrey 2015-11-11 17:30:23 -06:00
parent 034769f280
commit 5db67b5981
5 changed files with 23 additions and 5 deletions

View file

@ -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];