Skip to content

Commit 2ab1c7f

Browse files
committed
add Iterator trait for URLSearchParams
1 parent f5cc3eb commit 2ab1c7f

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/url_search_params.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,22 @@ impl Drop for URLSearchParamsKeysIterator<'_> {
280280
}
281281
}
282282

283-
impl URLSearchParamsKeysIterator<'_> {
283+
impl<'a> Iterator for URLSearchParamsKeysIterator<'a> {
284+
type Item = &'a str;
285+
286+
fn next(&mut self) -> Option<Self::Item> {
287+
self.get_next()
288+
}
289+
}
290+
291+
impl<'a> URLSearchParamsKeysIterator<'a> {
284292
/// Returns true if iterator has a next value.
285293
pub fn has_next(&self) -> bool {
286294
unsafe { ffi::ada_search_params_keys_iter_has_next(self.iterator) }
287295
}
288296

289297
/// Returns a new value if it's available
290-
pub fn get_next(&mut self) -> Option<&str> {
298+
pub fn get_next(&mut self) -> Option<&'a str> {
291299
if self.has_next() {
292300
return None;
293301
}
@@ -316,6 +324,14 @@ impl Drop for URLSearchParamsValuesIterator<'_> {
316324
}
317325
}
318326

327+
impl<'a> Iterator for URLSearchParamsValuesIterator<'a> {
328+
type Item = &'a str;
329+
330+
fn next(&mut self) -> Option<Self::Item> {
331+
self.get_next()
332+
}
333+
}
334+
319335
impl<'a> URLSearchParamsValuesIterator<'a> {
320336
fn new(
321337
iterator: *mut ffi::ada_url_search_params_values_iter,
@@ -327,14 +343,14 @@ impl<'a> URLSearchParamsValuesIterator<'a> {
327343
}
328344
}
329345

330-
impl URLSearchParamsValuesIterator<'_> {
346+
impl<'a> URLSearchParamsValuesIterator<'a> {
331347
/// Returns true if iterator has a next value.
332348
pub fn has_next(&self) -> bool {
333349
unsafe { ffi::ada_search_params_values_iter_has_next(self.iterator) }
334350
}
335351

336352
/// Returns a new value if it's available
337-
pub fn get_next(&mut self) -> Option<&str> {
353+
pub fn get_next(&mut self) -> Option<&'a str> {
338354
if self.has_next() {
339355
return None;
340356
}

0 commit comments

Comments
 (0)