File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
name = " url"
4
4
# When updating version, also modify html_root_url in the lib.rs
5
- version = " 1.6.0 "
5
+ version = " 1.6.1 "
6
6
authors = [" The rust-url developers" ]
7
7
8
8
description = " URL library for Rust, based on the WHATWG URL Standard"
Original file line number Diff line number Diff line change @@ -257,8 +257,16 @@ impl<'a> Target for &'a mut String {
257
257
// * `Serializer` keeps its target in a private field
258
258
// * Unlike in other `Target` impls, `UrlQuery::finished` does not return `Self`.
259
259
impl < ' a > Target for :: UrlQuery < ' a > {
260
- fn as_mut_string ( & mut self ) -> & mut String { & mut self . url . serialization }
261
- fn finish ( self ) -> & ' a mut :: Url { self . url }
260
+ fn as_mut_string ( & mut self ) -> & mut String {
261
+ & mut self . url . as_mut ( ) . unwrap ( ) . serialization
262
+ }
263
+
264
+ fn finish ( mut self ) -> & ' a mut :: Url {
265
+ let url = self . url . take ( ) . unwrap ( ) ;
266
+ url. restore_already_parsed_fragment ( self . fragment . take ( ) ) ;
267
+ url
268
+ }
269
+
262
270
type Finished = & ' a mut :: Url ;
263
271
}
264
272
Original file line number Diff line number Diff line change @@ -1304,7 +1304,7 @@ impl Url {
1304
1304
self . serialization . push ( '?' ) ;
1305
1305
}
1306
1306
1307
- let query = UrlQuery { url : self , fragment : fragment } ;
1307
+ let query = UrlQuery { url : Some ( self ) , fragment : fragment } ;
1308
1308
form_urlencoded:: Serializer :: for_suffix ( query, query_start + "?" . len ( ) )
1309
1309
}
1310
1310
@@ -2373,13 +2373,15 @@ fn io_error<T>(reason: &str) -> io::Result<T> {
2373
2373
/// Implementation detail of `Url::query_pairs_mut`. Typically not used directly.
2374
2374
#[ derive( Debug ) ]
2375
2375
pub struct UrlQuery < ' a > {
2376
- url : & ' a mut Url ,
2376
+ url : Option < & ' a mut Url > ,
2377
2377
fragment : Option < String > ,
2378
2378
}
2379
2379
2380
2380
impl < ' a > Drop for UrlQuery < ' a > {
2381
2381
fn drop ( & mut self ) {
2382
- self . url . restore_already_parsed_fragment ( self . fragment . take ( ) )
2382
+ if let Some ( url) = self . url . take ( ) {
2383
+ url. restore_already_parsed_fragment ( self . fragment . take ( ) )
2384
+ }
2383
2385
}
2384
2386
}
2385
2387
You can’t perform that action at this time.
0 commit comments