clippy: Fix redundant_* warnings (#32056)

* clippy: Fix `redundant_field_names` warnings

* clippy: Fix other `redundant_*` warnings

* docs: Update docstring comments
This commit is contained in:
eri 2024-04-11 23:46:18 +02:00 committed by GitHub
parent e3ad76d994
commit b3d9924396
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 68 additions and 73 deletions

View file

@ -18,13 +18,13 @@ use crate::dom::bindings::weakref::MutableWeakRef;
use crate::dom::globalscope::GlobalScope;
use crate::dom::url::URL;
// https://url.spec.whatwg.org/#interface-urlsearchparams
/// <https://url.spec.whatwg.org/#interface-urlsearchparams>
#[dom_struct]
pub struct URLSearchParams {
reflector_: Reflector,
// https://url.spec.whatwg.org/#concept-urlsearchparams-list
/// <https://url.spec.whatwg.org/#concept-urlsearchparams-list>
list: DomRefCell<Vec<(String, String)>>,
// https://url.spec.whatwg.org/#concept-urlsearchparams-url-object
/// <https://url.spec.whatwg.org/#concept-urlsearchparams-url-object>
url: MutableWeakRef<URL>,
}
@ -49,7 +49,7 @@ impl URLSearchParams {
reflect_dom_object_with_proto(Box::new(URLSearchParams::new_inherited(url)), global, proto)
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
/// <https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams>
#[allow(non_snake_case)]
pub fn Constructor(
global: &GlobalScope,
@ -79,7 +79,7 @@ impl URLSearchParams {
USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVString(init) => {
// Step 4.
let init_bytes = match init.0.chars().next() {
Some(first_char) if first_char == '?' => {
Some('?') => {
let (_, other_bytes) = init.0.as_bytes().split_at(1);
other_bytes
@ -102,12 +102,12 @@ impl URLSearchParams {
}
impl URLSearchParamsMethods for URLSearchParams {
// https://url.spec.whatwg.org/#dom-urlsearchparams-size
/// <https://url.spec.whatwg.org/#dom-urlsearchparams-size>
fn Size(&self) -> u32 {
self.list.borrow().len() as u32
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-append
/// <https://url.spec.whatwg.org/#dom-urlsearchparams-append>
fn Append(&self, name: USVString, value: USVString) {
// Step 1.
self.list.borrow_mut().push((name.0, value.0));
@ -115,7 +115,7 @@ impl URLSearchParamsMethods for URLSearchParams {
self.update_steps();
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-delete
/// <https://url.spec.whatwg.org/#dom-urlsearchparams-delete>
fn Delete(&self, name: USVString, value: Option<USVString>) {
// Step 1.
self.list.borrow_mut().retain(|(k, v)| match &value {
@ -126,7 +126,7 @@ impl URLSearchParamsMethods for URLSearchParams {
self.update_steps();
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-get
/// <https://url.spec.whatwg.org/#dom-urlsearchparams-get>
fn Get(&self, name: USVString) -> Option<USVString> {
let list = self.list.borrow();
list.iter()
@ -134,7 +134,7 @@ impl URLSearchParamsMethods for URLSearchParams {
.map(|kv| USVString(kv.1.clone()))
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-getall
/// <https://url.spec.whatwg.org/#dom-urlsearchparams-getall>
fn GetAll(&self, name: USVString) -> Vec<USVString> {
let list = self.list.borrow();
list.iter()
@ -148,7 +148,7 @@ impl URLSearchParamsMethods for URLSearchParams {
.collect()
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-has
/// <https://url.spec.whatwg.org/#dom-urlsearchparams-has>
fn Has(&self, name: USVString, value: Option<USVString>) -> bool {
let list = self.list.borrow();
list.iter().any(|(k, v)| match &value {
@ -157,7 +157,7 @@ impl URLSearchParamsMethods for URLSearchParams {
})
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-set
/// <https://url.spec.whatwg.org/#dom-urlsearchparams-set>
fn Set(&self, name: USVString, value: USVString) {
{
// Step 1.
@ -185,7 +185,7 @@ impl URLSearchParamsMethods for URLSearchParams {
self.update_steps();
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-sort
/// <https://url.spec.whatwg.org/#dom-urlsearchparams-sort>
fn Sort(&self) {
// Step 1.
self.list
@ -196,14 +196,14 @@ impl URLSearchParamsMethods for URLSearchParams {
self.update_steps();
}
// https://url.spec.whatwg.org/#stringification-behavior
/// <https://url.spec.whatwg.org/#stringification-behavior>
fn Stringifier(&self) -> DOMString {
DOMString::from(self.serialize_utf8())
}
}
impl URLSearchParams {
// https://url.spec.whatwg.org/#concept-urlencoded-serializer
/// <https://url.spec.whatwg.org/#concept-urlencoded-serializer>
pub fn serialize_utf8(&self) -> String {
let list = self.list.borrow();
form_urlencoded::Serializer::new(String::new())
@ -211,7 +211,7 @@ impl URLSearchParams {
.finish()
}
// https://url.spec.whatwg.org/#concept-urlsearchparams-update
/// <https://url.spec.whatwg.org/#concept-urlsearchparams-update>
fn update_steps(&self) {
if let Some(url) = self.url.root() {
url.set_query_pairs(&self.list.borrow())