File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,28 @@ impl core::fmt::Display for URLSearchParams {
224224 }
225225}
226226
227+ #[ cfg( feature = "std" ) ]
228+ impl < Input > Extend < ( Input , Input ) > for URLSearchParams
229+ where
230+ Input : AsRef < str > ,
231+ {
232+ /// Supports extending URLSearchParams through an iterator.
233+ ///
234+ ///```
235+ /// use ada_url::URLSearchParams;
236+ /// let mut params = URLSearchParams::parse("a=1&b=2")
237+ /// .expect("This is a valid URLSearchParams. Should have parsed it.");
238+ /// assert_eq!(params.len(), 2);
239+ /// params.extend([("foo", "bar")]);
240+ /// assert_eq!(params.len(), 3);
241+ /// ```
242+ fn extend < T : IntoIterator < Item = ( Input , Input ) > > ( & mut self , iter : T ) {
243+ for item in iter {
244+ self . append ( item. 0 . as_ref ( ) , item. 1 . as_ref ( ) ) ;
245+ }
246+ }
247+ }
248+
227249pub struct URLSearchParamsKeysIterator < ' a > {
228250 iterator : * mut ffi:: ada_url_search_params_keys_iter ,
229251 _phantom : core:: marker:: PhantomData < & ' a str > ,
You can’t perform that action at this time.
0 commit comments