fixed various clippy warnings (#31954)

This commit is contained in:
Rosemary Ajayi 2024-03-31 19:58:37 +00:00 committed by GitHub
parent c3360df918
commit bd287df0d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 6 additions and 6 deletions

View file

@ -258,7 +258,7 @@ impl AudioNodeMethods for AudioNode {
EventTargetTypeId::AudioNode(AudioNodeTypeId::AudioDestinationNode) => { EventTargetTypeId::AudioNode(AudioNodeTypeId::AudioDestinationNode) => {
if self.context.is_offline() { if self.context.is_offline() {
return Err(Error::InvalidState); return Err(Error::InvalidState);
} else if value < 1 || value > MAX_CHANNEL_COUNT { } else if !(1..=MAX_CHANNEL_COUNT).contains(&value) {
return Err(Error::IndexSize); return Err(Error::IndexSize);
} }
}, },

View file

@ -197,7 +197,7 @@ pub unsafe fn get_array_index_from_id(_cx: *mut JSContext, id: HandleId) -> Opti
let first_char = char::decode_utf16(chars.iter().cloned()) let first_char = char::decode_utf16(chars.iter().cloned())
.next() .next()
.map_or('\0', |r| r.unwrap_or('\0')); .map_or('\0', |r| r.unwrap_or('\0'));
if !('a'..='z').contains(&first_char) { if !first_char.is_ascii_lowercase() {
return None; return None;
} }

View file

@ -322,5 +322,5 @@ pub fn normalize_type_string(s: &str) -> String {
fn is_ascii_printable(string: &str) -> bool { fn is_ascii_printable(string: &str) -> bool {
// Step 5.1 in Sec 5.1 of File API spec // Step 5.1 in Sec 5.1 of File API spec
// <https://w3c.github.io/FileAPI/#constructorBlob> // <https://w3c.github.io/FileAPI/#constructorBlob>
string.chars().all(|c| c >= '\x20' && c <= '\x7E') string.chars().all(|c| ('\x20'..='\x7E').contains(&c))
} }

View file

@ -523,7 +523,7 @@ const BLUETOOTH_ASSIGNED_CHARCTERISTICS: &[(&str, u32)] = &[
]; ];
//https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx //https://developer.bluetooth.org/gatt/services/Pages/ServicesHome.aspx
const BLUETOOTH_ASSIGNED_DESCRIPTORS: &'static [(&str, u32)] = &[ const BLUETOOTH_ASSIGNED_DESCRIPTORS: &[(&str, u32)] = &[
( (
"org.bluetooth.descriptor.gatt.characteristic_extended_properties", "org.bluetooth.descriptor.gatt.characteristic_extended_properties",
0x2900_u32, 0x2900_u32,

View file

@ -148,7 +148,7 @@ impl CharacterDataMethods for CharacterData {
Err(()) => substring += remaining, Err(()) => substring += remaining,
// Steps 4. // Steps 4.
Ok((s, astral, _)) => { Ok((s, astral, _)) => {
substring = substring + s; substring += s;
// As if we had split the UTF-16 surrogate pair in half // As if we had split the UTF-16 surrogate pair in half
// and then transcoded that to UTF-8 lossily, // and then transcoded that to UTF-8 lossily,
// since our DOMString is currently strict UTF-8. // since our DOMString is currently strict UTF-8.

View file

@ -57,7 +57,7 @@ impl CSSNamespaceRuleMethods for CSSNamespaceRule {
.prefix .prefix
.as_ref() .as_ref()
.map(|s| s.to_string().into()) .map(|s| s.to_string().into())
.unwrap_or(DOMString::new()) .unwrap_or_default()
} }
// https://drafts.csswg.org/cssom/#dom-cssnamespacerule-namespaceuri // https://drafts.csswg.org/cssom/#dom-cssnamespacerule-namespaceuri