Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Dec 1, 2024
1 parent ac2efd0 commit 7652e33
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/url_search_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ impl URLSearchParams {
if out.data.is_null() {
return None;
}
let slice = core::slice::from_raw_parts(out.data.cast(), out.length);
Some(core::str::from_utf8_unchecked(slice))
Some(out.as_str())
}
}

Expand Down Expand Up @@ -165,7 +164,6 @@ impl URLSearchParams {
unsafe {
let strings = ffi::ada_search_params_get_all(self.0, key.as_ptr().cast(), key.len());
let size = ffi::ada_strings_size(strings);

URLSearchParamsEntry::new(strings, size)
}
}
Expand Down Expand Up @@ -200,13 +198,13 @@ pub struct URLSearchParamsKeysIterator<'a> {
_phantom: core::marker::PhantomData<&'a str>,
}

impl<'a> Drop for URLSearchParamsKeysIterator<'a> {
impl Drop for URLSearchParamsKeysIterator<'_> {
fn drop(&mut self) {
unsafe { ffi::ada_free_search_params_keys_iter(self.iterator) }
}
}

impl<'a> URLSearchParamsKeysIterator<'a> {
impl URLSearchParamsKeysIterator<'_> {
/// Returns true if iterator has a next value.
pub fn has_next(&self) -> bool {
unsafe { ffi::ada_search_params_keys_iter_has_next(self.iterator) }
Expand Down Expand Up @@ -236,7 +234,7 @@ impl<'a> URLSearchParamsKeysIterator<'a> {
}
}

impl<'a> Drop for URLSearchParamsValuesIterator<'a> {
impl Drop for URLSearchParamsValuesIterator<'_> {
fn drop(&mut self) {
unsafe { ffi::ada_free_search_params_values_iter(self.iterator) }
}
Expand All @@ -253,7 +251,7 @@ impl<'a> URLSearchParamsValuesIterator<'a> {
}
}

impl<'a> URLSearchParamsValuesIterator<'a> {
impl URLSearchParamsValuesIterator<'_> {
/// Returns true if iterator has a next value.
pub fn has_next(&self) -> bool {
unsafe { ffi::ada_search_params_values_iter_has_next(self.iterator) }
Expand Down Expand Up @@ -327,14 +325,12 @@ impl<'a> URLSearchParamsEntry<'a> {

unsafe {
let string = ffi::ada_strings_get(self.strings, index);
let slice = core::slice::from_raw_parts(string.data.cast(), string.length);
Some(core::str::from_utf8_unchecked(slice))
Some(string.as_str())
}
}
}

impl<'a> Drop for URLSearchParamsEntry<'a> {
/// Automatically frees the underlying C pointer.
impl Drop for URLSearchParamsEntry<'_> {
fn drop(&mut self) {
unsafe { ffi::ada_free_strings(self.strings) }
}
Expand Down

0 comments on commit 7652e33

Please sign in to comment.