mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +01:00
Script: Change script/dom/{bluetooth,canvas,html} to not rely on Deref<str> for DOMString (#39480)
This is part of the future work of implementing LazyDOMString as outlined in https://github.com/servo/servo/issues/39479. We use str() method or direct implementations on DOMString for these methods. We also change some types. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> Testing: This is essentially just renaming a method and a type and should not change functionality. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
parent
1e471b9b41
commit
a4c8ffe753
23 changed files with 97 additions and 95 deletions
|
@ -212,6 +212,10 @@ impl DOMString {
|
|||
&self.0
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0.is_empty()
|
||||
}
|
||||
|
||||
/// Appends a given string slice onto the end of this String.
|
||||
pub fn push_str(&mut self, string: &str) {
|
||||
self.0.push_str(string)
|
||||
|
@ -311,10 +315,6 @@ impl DOMString {
|
|||
self.0.len()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0.is_empty()
|
||||
}
|
||||
|
||||
pub fn chars(&self) -> Chars<'_> {
|
||||
self.0.chars()
|
||||
}
|
||||
|
@ -433,7 +433,6 @@ impl Default for DOMString {
|
|||
|
||||
impl Deref for DOMString {
|
||||
type Target = str;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &str {
|
||||
&self.0
|
||||
|
@ -456,13 +455,13 @@ impl AsRef<str> for DOMString {
|
|||
impl fmt::Display for DOMString {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fmt::Display::fmt(&**self, f)
|
||||
fmt::Display::fmt(self.str(), f)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<str> for DOMString {
|
||||
fn eq(&self, other: &str) -> bool {
|
||||
&**self == other
|
||||
self.str() == other
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,7 +473,19 @@ impl PartialEq<DOMString> for str {
|
|||
|
||||
impl<'a> PartialEq<&'a str> for DOMString {
|
||||
fn eq(&self, other: &&'a str) -> bool {
|
||||
&**self == *other
|
||||
self.str() == *other
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<DOMString> for String {
|
||||
fn eq(&self, other: &DOMString) -> bool {
|
||||
*other.0 == *self
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq<String> for DOMString {
|
||||
fn eq(&self, other: &String) -> bool {
|
||||
self.0 == *other
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue