Script: Remove last instances of Deref<str> and DerefMut<str> used for DOMString (#39504)

This removes the last instances of Deref<str> and DerefMut<str> used for
DOMString.
The goal is outlined in https://github.com/servo/servo/issues/39479.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: Compilation is the test as it just changes function names
essentially.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
Narfinger 2025-09-27 03:48:24 +02:00 committed by GitHub
parent 89293995f0
commit 18a1da0d80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 85 additions and 84 deletions

View file

@ -8,7 +8,7 @@ use std::default::Default;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
use std::str::{Chars, EncodeUtf16, FromStr};
use std::str::{CharIndices, Chars, EncodeUtf16, FromStr};
use std::sync::LazyLock;
use std::{fmt, ops, slice, str};
@ -358,6 +358,24 @@ impl DOMString {
pub fn contains_html_space_characters(&self) -> bool {
self.0.contains(HTML_SPACE_CHARACTERS)
}
pub fn split_html_space_characters(&self) -> impl Iterator<Item = &str> {
self.0
.split(HTML_SPACE_CHARACTERS)
.filter(|s| !s.is_empty())
}
pub fn char_indices(&self) -> CharIndices<'_> {
self.0.char_indices()
}
pub fn strip_prefix(&self, pattern: &str) -> Option<&str> {
self.0.strip_prefix(pattern)
}
pub fn split(&self, c: char) -> impl Iterator<Item = &str> {
self.0.split(c)
}
}
/// Because this converts to a DOMString it becomes UTF-8 encoded which is closer to
@ -431,27 +449,6 @@ impl Default for DOMString {
}
}
impl Deref for DOMString {
type Target = str;
#[inline]
fn deref(&self) -> &str {
&self.0
}
}
impl DerefMut for DOMString {
#[inline]
fn deref_mut(&mut self) -> &mut str {
&mut self.0
}
}
impl AsRef<str> for DOMString {
fn as_ref(&self) -> &str {
&self.0
}
}
impl fmt::Display for DOMString {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {