clippy: Fix a few problems in components/script/dom (#31955)

* fixed various clippy warnings

* fixed various clippy warnings

* fixed various clippy warnings
This commit is contained in:
Rosemary Ajayi 2024-03-31 23:15:13 +00:00 committed by GitHub
parent 9401102691
commit 00c4d798c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 9 deletions

View file

@ -90,7 +90,7 @@ pub struct FileReaderSharedFunctionality;
impl FileReaderSharedFunctionality {
pub fn dataurl_format(blob_contents: &[u8], blob_type: String) -> DOMString {
let base64 = base64::engine::general_purpose::STANDARD.encode(&blob_contents);
let base64 = base64::engine::general_purpose::STANDARD.encode(blob_contents);
let dataurl = if blob_type.is_empty() {
format!("data:base64,{}", base64)

View file

@ -1186,9 +1186,7 @@ impl HTMLScriptElement {
(Some(ref ty), _) => {
debug!("script type={}", &***ty);
if ty.to_ascii_lowercase().trim_matches(HTML_SPACE_CHARACTERS) ==
String::from("module")
{
if ty.to_ascii_lowercase().trim_matches(HTML_SPACE_CHARACTERS) == "module" {
return Some(ScriptType::Module);
}

View file

@ -296,11 +296,11 @@ impl Range {
}
fn start(&self) -> &BoundaryPoint {
&self.abstract_range().start()
self.abstract_range().start()
}
fn end(&self) -> &BoundaryPoint {
&self.abstract_range().end()
self.abstract_range().end()
}
pub fn start_container(&self) -> DomRoot<Node> {

View file

@ -874,7 +874,7 @@ impl TestBindingMethods for TestBinding {
.get(pref_name.as_ref())
.as_str()
.map(DOMString::from)
.unwrap_or_else(DOMString::new)
.unwrap_or_default()
}
fn PrefControlledAttributeDisabled(&self) -> bool {
false

View file

@ -106,13 +106,13 @@ impl VertexArrayObject {
.get_mut(index as usize)
.ok_or(WebGLError::InvalidValue)?;
if size < 1 || size > 4 {
if !(1..=4).contains(&size) {
return Err(WebGLError::InvalidValue);
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#BUFFER_OFFSET_AND_STRIDE
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#VERTEX_STRIDE
if stride < 0 || stride > 255 || offset < 0 {
if !(0..=255).contains(&stride) || offset < 0 {
return Err(WebGLError::InvalidValue);
}