Skip to content

Commit

Permalink
add Iterator trait for URLSearchParams
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Dec 1, 2024
1 parent f5cc3eb commit b9811ac
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/url_search_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,22 @@ impl Drop for URLSearchParamsKeysIterator<'_> {
}
}

impl URLSearchParamsKeysIterator<'_> {
impl<'a> Iterator for URLSearchParamsKeysIterator<'a> {
type Item = &'a str;

fn next(&mut self) -> Option<Self::Item> {
self.get_next()
}
}

impl<'a> URLSearchParamsKeysIterator<'a> {
/// 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) }
}

/// Returns a new value if it's available
pub fn get_next(&mut self) -> Option<&str> {
pub fn get_next(&mut self) -> Option<&'a str> {
if self.has_next() {
return None;
}
Expand Down

0 comments on commit b9811ac

Please sign in to comment.