File tree Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 33All notable changes to this project will be documented in this file.
44This project uses [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
55
6+ ## [ 0.3.0] - 2023-07-08
7+
8+ ### Added
9+
10+ - Added the ` append ` and ` append_into ` functions.
11+
612## [ 0.2.0] - 2023-07-07
713
814### Added
915
10- - Added the ` with_opt_value ` and ` push_opt ` helper methods .
16+ - Added the ` with_opt_value ` and ` push_opt ` functions .
1117
1218## [ 0.1.0] - 2023-07-07
1319
1420### Internal
1521
1622- 🎉 Initial release.
1723
24+ [ 0.3.0 ] : https://github.com/sunsided/query-string-builder/releases/tag/0.3.0
1825[ 0.2.0 ] : https://github.com/sunsided/query-string-builder/releases/tag/0.2.0
1926[ 0.1.0 ] : https://github.com/sunsided/query-string-builder/releases/tag/0.1.0
Original file line number Diff line number Diff line change 22name = " query-string-builder"
33description = " A query string builder for percent encoding key-value pairs"
44authors = [" Markus Mayer" ]
5- version = " 0.2 .0"
5+ version = " 0.3 .0"
66edition = " 2021"
77repository = " https://github.com/sunsided/query-string-builder"
88keywords = [" url" , " query-string" , " query-argument" ]
Original file line number Diff line number Diff line change @@ -156,6 +156,49 @@ impl<'a> QueryString<'a> {
156156 pub fn is_empty ( & self ) -> bool {
157157 self . pairs . is_empty ( )
158158 }
159+
160+ /// Appends another query string builder's values.
161+ ///
162+ /// ## Example
163+ ///
164+ /// ```
165+ /// use query_string_builder::QueryString;
166+ ///
167+ /// let mut qs = QueryString::new().with_value("q", "apple");
168+ /// let more = QueryString::new().with_value("q", "pear");
169+ ///
170+ /// qs.append(more);
171+ ///
172+ /// assert_eq!(
173+ /// format!("https://example.com/{qs}"),
174+ /// "https://example.com/?q=apple&q=pear"
175+ /// );
176+ /// ```
177+ pub fn append ( & mut self , mut other : QueryString < ' a > ) {
178+ self . pairs . append ( & mut other. pairs )
179+ }
180+
181+ /// Appends another query string builder's values, consuming both types.
182+ ///
183+ /// ## Example
184+ ///
185+ /// ```
186+ /// use query_string_builder::QueryString;
187+ ///
188+ /// let qs = QueryString::new().with_value("q", "apple");
189+ /// let more = QueryString::new().with_value("q", "pear");
190+ ///
191+ /// let qs = qs.append_into(more);
192+ ///
193+ /// assert_eq!(
194+ /// format!("https://example.com/{qs}"),
195+ /// "https://example.com/?q=apple&q=pear"
196+ /// );
197+ /// ```
198+ pub fn append_into ( mut self , mut other : QueryString < ' a > ) -> Self {
199+ self . pairs . append ( & mut other. pairs ) ;
200+ self
201+ }
159202}
160203
161204impl < ' a > Display for QueryString < ' a > {
You can’t perform that action at this time.
0 commit comments