Skip to content

Commit c7bc022

Browse files
committed
fix clippy warnings
1 parent d52d366 commit c7bc022

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/url_search_params.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ impl URLSearchParams {
135135
if out.data.is_null() {
136136
return None;
137137
}
138-
let slice = core::slice::from_raw_parts(out.data.cast(), out.length);
139-
Some(core::str::from_utf8_unchecked(slice))
138+
Some(out.as_str())
140139
}
141140
}
142141

@@ -165,7 +164,6 @@ impl URLSearchParams {
165164
unsafe {
166165
let strings = ffi::ada_search_params_get_all(self.0, key.as_ptr().cast(), key.len());
167166
let size = ffi::ada_strings_size(strings);
168-
169167
URLSearchParamsEntry::new(strings, size)
170168
}
171169
}
@@ -200,13 +198,13 @@ pub struct URLSearchParamsKeysIterator<'a> {
200198
_phantom: core::marker::PhantomData<&'a str>,
201199
}
202200

203-
impl<'a> Drop for URLSearchParamsKeysIterator<'a> {
201+
impl Drop for URLSearchParamsKeysIterator<'_> {
204202
fn drop(&mut self) {
205203
unsafe { ffi::ada_free_search_params_keys_iter(self.iterator) }
206204
}
207205
}
208206

209-
impl<'a> URLSearchParamsKeysIterator<'a> {
207+
impl URLSearchParamsKeysIterator<'_> {
210208
/// Returns true if iterator has a next value.
211209
pub fn has_next(&self) -> bool {
212210
unsafe { ffi::ada_search_params_keys_iter_has_next(self.iterator) }
@@ -236,7 +234,7 @@ impl<'a> URLSearchParamsKeysIterator<'a> {
236234
}
237235
}
238236

239-
impl<'a> Drop for URLSearchParamsValuesIterator<'a> {
237+
impl Drop for URLSearchParamsValuesIterator<'_> {
240238
fn drop(&mut self) {
241239
unsafe { ffi::ada_free_search_params_values_iter(self.iterator) }
242240
}
@@ -253,7 +251,7 @@ impl<'a> URLSearchParamsValuesIterator<'a> {
253251
}
254252
}
255253

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

328326
unsafe {
329327
let string = ffi::ada_strings_get(self.strings, index);
330-
let slice = core::slice::from_raw_parts(string.data.cast(), string.length);
331-
Some(core::str::from_utf8_unchecked(slice))
328+
Some(string.as_str())
332329
}
333330
}
334331
}
335332

336-
impl<'a> Drop for URLSearchParamsEntry<'a> {
337-
/// Automatically frees the underlying C pointer.
333+
impl Drop for URLSearchParamsEntry<'_> {
338334
fn drop(&mut self) {
339335
unsafe { ffi::ada_free_strings(self.strings) }
340336
}

0 commit comments

Comments
 (0)