forked from diesel-rs/diesel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct.Url.html
More file actions
766 lines (636 loc) · 175 KB
/
Copy pathstruct.Url.html
File metadata and controls
766 lines (636 loc) · 175 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A parsed URL record."><meta name="keywords" content="rust, rustlang, rust-lang, Url"><title>Url in url - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../url/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
</a><h2 class="location"></h2>
</nav>
<nav class="sidebar"><a class="sidebar-logo" href="../url/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
</a><h2 class="location"><a href="#">Url</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#implementations">Methods</a></h3><ul><li><a href="#method.as_str">as_str</a></li><li><a href="#method.cannot_be_a_base">cannot_be_a_base</a></li><li><a href="#method.domain">domain</a></li><li><a href="#method.fragment">fragment</a></li><li><a href="#method.from_directory_path">from_directory_path</a></li><li><a href="#method.from_file_path">from_file_path</a></li><li><a href="#method.has_authority">has_authority</a></li><li><a href="#method.has_host">has_host</a></li><li><a href="#method.host">host</a></li><li><a href="#method.host_str">host_str</a></li><li><a href="#method.into_string">into_string</a></li><li><a href="#method.join">join</a></li><li><a href="#method.make_relative">make_relative</a></li><li><a href="#method.options">options</a></li><li><a href="#method.origin">origin</a></li><li><a href="#method.parse">parse</a></li><li><a href="#method.parse_with_params">parse_with_params</a></li><li><a href="#method.password">password</a></li><li><a href="#method.path">path</a></li><li><a href="#method.path_segments">path_segments</a></li><li><a href="#method.path_segments_mut">path_segments_mut</a></li><li><a href="#method.port">port</a></li><li><a href="#method.port_or_known_default">port_or_known_default</a></li><li><a href="#method.query">query</a></li><li><a href="#method.query_pairs">query_pairs</a></li><li><a href="#method.query_pairs_mut">query_pairs_mut</a></li><li><a href="#method.scheme">scheme</a></li><li><a href="#method.set_fragment">set_fragment</a></li><li><a href="#method.set_host">set_host</a></li><li><a href="#method.set_ip_host">set_ip_host</a></li><li><a href="#method.set_password">set_password</a></li><li><a href="#method.set_path">set_path</a></li><li><a href="#method.set_port">set_port</a></li><li><a href="#method.set_query">set_query</a></li><li><a href="#method.set_scheme">set_scheme</a></li><li><a href="#method.set_username">set_username</a></li><li><a href="#method.socket_addrs">socket_addrs</a></li><li><a href="#method.to_file_path">to_file_path</a></li><li><a href="#method.username">username</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#trait-implementations">Trait Implementations</a></h3><ul><li><a href="#impl-AsRef%3Cstr%3E">AsRef<str></a></li><li><a href="#impl-Clone">Clone</a></li><li><a href="#impl-Debug">Debug</a></li><li><a href="#impl-Display">Display</a></li><li><a href="#impl-Eq">Eq</a></li><li><a href="#impl-From%3CUrl%3E">From<Url></a></li><li><a href="#impl-FromStr">FromStr</a></li><li><a href="#impl-Hash">Hash</a></li><li><a href="#impl-Index%3CRange%3CPosition%3E%3E">Index<Range<Position>></a></li><li><a href="#impl-Index%3CRangeFrom%3CPosition%3E%3E">Index<RangeFrom<Position>></a></li><li><a href="#impl-Index%3CRangeFull%3E">Index<RangeFull></a></li><li><a href="#impl-Index%3CRangeTo%3CPosition%3E%3E">Index<RangeTo<Position>></a></li><li><a href="#impl-Ord">Ord</a></li><li><a href="#impl-PartialEq%3CUrl%3E">PartialEq<Url></a></li><li><a href="#impl-PartialOrd%3CUrl%3E">PartialOrd<Url></a></li><li><a href="#impl-TryFrom%3C%26%27a%20str%3E">TryFrom<&'a str></a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul><li><a href="#impl-RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send">Send</a></li><li><a href="#impl-Sync">Sync</a></li><li><a href="#impl-Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe">UnwindSafe</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#blanket-implementations">Blanket Implementations</a></h3><ul><li><a href="#impl-Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E">From<T></a></li><li><a href="#impl-Into%3CU%3E">Into<U></a></li><li><a href="#impl-ToOwned">ToOwned</a></li><li><a href="#impl-ToString">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E">TryInto<U></a></li></ul></div></section><h2 class="location"><a href="index.html">In url</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../url/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1">
<a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div>
</div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
<h1 class="fqn"><span class="in-band">Struct <a href="index.html">url</a>::<wbr><a class="struct" href="#">Url</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/url/lib.rs.html#166-188">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust struct"><code>pub struct Url { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A parsed URL record.</p>
</div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#252-2486">source</a></span><a href="#impl" class="anchor"></a><h3 class="code-header in-band">impl <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.parse" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#275-277">source</a></span><a href="#method.parse" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.parse" class="fnname">parse</a>(input: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>></h4></section></summary><div class="docblock"><p>Parse an absolute URL from a string.</p>
<h5 id="examples"><a href="#examples">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;</code></pre></div>
<h5 id="errors"><a href="#errors">Errors</a></h5>
<p>If the function can not parse an absolute URL from the given string,
a <a href="enum.ParseError.html"><code>ParseError</code></a> variant will be returned.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.parse_with_params" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#305-319">source</a></span><a href="#method.parse_with_params" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.parse_with_params" class="fnname">parse_with_params</a><I, K, V>(<br> input: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br> iter: I<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>> <span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>,<br> I::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::collect::IntoIterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(K, V)</a>>,<br> K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>,<br> V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>, </span></h4></section></summary><div class="docblock"><p>Parse an absolute URL from a string and add params to its query string.</p>
<p>Existing params are not removed.</p>
<h5 id="examples-1"><a href="#examples-1">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse_with_params</span>(<span class="string">"https://example.net?dont=clobberme"</span>,
<span class="kw-2">&</span>[(<span class="string">"lang"</span>, <span class="string">"rust"</span>), (<span class="string">"browser"</span>, <span class="string">"servo"</span>)])<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="string">"https://example.net/?dont=clobberme&lang=rust&browser=servo"</span>, <span class="ident">url</span>.<span class="ident">as_str</span>());</code></pre></div>
<h5 id="errors-1"><a href="#errors-1">Errors</a></h5>
<p>If the function can not parse an absolute URL from the given string,
a <a href="enum.ParseError.html"><code>ParseError</code></a> variant will be returned.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.join" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#356-358">source</a></span><a href="#method.join" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.join" class="fnname">join</a>(&self, input: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>></h4></section></summary><div class="docblock"><p>Parse a string as an URL, with this URL as the base URL.</p>
<p>The inverse of this is <a href="#method.make_relative"><code>make_relative</code></a>.</p>
<p>Note: a trailing slash is significant.
Without it, the last path component is considered to be a “file” name
to be removed to get at the “directory” that is used as the base:</p>
<h5 id="examples-2"><a href="#examples-2">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">base</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/b.html"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">base</span>.<span class="ident">join</span>(<span class="string">"c.png"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.net/a/c.png"</span>); <span class="comment">// Not /a/b.html/c.png</span>
<span class="kw">let</span> <span class="ident">base</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/b/"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">base</span>.<span class="ident">join</span>(<span class="string">"c.png"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.net/a/b/c.png"</span>);</code></pre></div>
<h5 id="errors-2"><a href="#errors-2">Errors</a></h5>
<p>If the function can not parse an URL from the given string
with this URL as the base URL, a <a href="enum.ParseError.html"><code>ParseError</code></a> variant will be returned.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.make_relative" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#401-490">source</a></span><a href="#method.make_relative" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.make_relative" class="fnname">make_relative</a>(&self, url: &<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>></h4></section></summary><div class="docblock"><p>Creates a relative URL if possible, with this URL as the base URL.</p>
<p>This is the inverse of <a href="#method.join"><code>join</code></a>.</p>
<h5 id="examples-3"><a href="#examples-3">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">base</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/b.html"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/c.png"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">relative</span> <span class="op">=</span> <span class="ident">base</span>.<span class="ident">make_relative</span>(<span class="kw-2">&</span><span class="ident">url</span>);
<span class="macro">assert_eq!</span>(<span class="ident">relative</span>.<span class="ident">as_ref</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">as_str</span>()), <span class="prelude-val">Some</span>(<span class="string">"c.png"</span>));
<span class="kw">let</span> <span class="ident">base</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/b/"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/b/c.png"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">relative</span> <span class="op">=</span> <span class="ident">base</span>.<span class="ident">make_relative</span>(<span class="kw-2">&</span><span class="ident">url</span>);
<span class="macro">assert_eq!</span>(<span class="ident">relative</span>.<span class="ident">as_ref</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">as_str</span>()), <span class="prelude-val">Some</span>(<span class="string">"c.png"</span>));
<span class="kw">let</span> <span class="ident">base</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/b/"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/d/c.png"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">relative</span> <span class="op">=</span> <span class="ident">base</span>.<span class="ident">make_relative</span>(<span class="kw-2">&</span><span class="ident">url</span>);
<span class="macro">assert_eq!</span>(<span class="ident">relative</span>.<span class="ident">as_ref</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">as_str</span>()), <span class="prelude-val">Some</span>(<span class="string">"../d/c.png"</span>));
<span class="kw">let</span> <span class="ident">base</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/b.html?c=d"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net/a/b.html?e=f"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">relative</span> <span class="op">=</span> <span class="ident">base</span>.<span class="ident">make_relative</span>(<span class="kw-2">&</span><span class="ident">url</span>);
<span class="macro">assert_eq!</span>(<span class="ident">relative</span>.<span class="ident">as_ref</span>().<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">as_str</span>()), <span class="prelude-val">Some</span>(<span class="string">"?e=f"</span>));</code></pre></div>
<h5 id="errors-3"><a href="#errors-3">Errors</a></h5>
<p>If this URL can’t be a base for the given URL, <code>None</code> is returned.
This is for example the case if the scheme, host or port are not the same.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.options" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#511-517">source</a></span><a href="#method.options" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.options" class="fnname">options</a><'a>() -> <a class="struct" href="struct.ParseOptions.html" title="struct url::ParseOptions">ParseOptions</a><'a></h4></section></summary><div class="docblock"><p>Return a default <code>ParseOptions</code> that can fully configure the URL parser.</p>
<h5 id="examples-4"><a href="#examples-4">Examples</a></h5>
<p>Get default <code>ParseOptions</code>, then change base url</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">options</span> <span class="op">=</span> <span class="ident">Url::options</span>();
<span class="kw">let</span> <span class="ident">api</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://api.example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">base_url</span> <span class="op">=</span> <span class="ident">options</span>.<span class="ident">base_url</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="ident">api</span>));
<span class="kw">let</span> <span class="ident">version_url</span> <span class="op">=</span> <span class="ident">base_url</span>.<span class="ident">parse</span>(<span class="string">"version.json"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">version_url</span>.<span class="ident">as_str</span>(), <span class="string">"https://api.example.com/version.json"</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_str" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#538-540">source</a></span><a href="#method.as_str" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.as_str" class="fnname">as_str</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Return the serialization of this URL.</p>
<p>This is fast since that serialization is already stored in the <code>Url</code> struct.</p>
<h5 id="examples-5"><a href="#examples-5">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url_str</span> <span class="op">=</span> <span class="string">"https://example.net/"</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="ident">url_str</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="ident">url_str</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into_string" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#562-564">source</a></span><a href="#method.into_string" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.into_string" class="fnname">into_string</a>(self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span> Deprecated since 2.3.0: <p>use Into<String></p>
</div></span></summary><div class="docblock"><p>Return the serialization of this URL.</p>
<p>This consumes the <code>Url</code> and takes ownership of the <code>String</code> stored in it.</p>
<h5 id="examples-6"><a href="#examples-6">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url_str</span> <span class="op">=</span> <span class="string">"https://example.net/"</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="ident">url_str</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">String::from</span>(<span class="ident">url</span>), <span class="ident">url_str</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.origin" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#761-763">source</a></span><a href="#method.origin" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.origin" class="fnname">origin</a>(&self) -> <a class="enum" href="enum.Origin.html" title="enum url::Origin">Origin</a></h4></section></summary><div class="docblock"><p>Return the origin of this URL (<a href="https://url.spec.whatwg.org/#origin">https://url.spec.whatwg.org/#origin</a>)</p>
<p>Note: this returns an opaque origin for <code>file:</code> URLs, which causes
<code>url.origin() != url.origin()</code>.</p>
<h5 id="examples-7"><a href="#examples-7">Examples</a></h5>
<p>URL with <code>ftp</code> scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Host</span>, <span class="ident">Origin</span>, <span class="ident">Url</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://example.com/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">origin</span>(),
<span class="ident">Origin::Tuple</span>(<span class="string">"ftp"</span>.<span class="ident">into</span>(),
<span class="ident">Host::Domain</span>(<span class="string">"example.com"</span>.<span class="ident">into</span>()),
<span class="number">21</span>));</code></pre></div>
<p>URL with <code>blob</code> scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Host</span>, <span class="ident">Origin</span>, <span class="ident">Url</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"blob:https://example.com/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">origin</span>(),
<span class="ident">Origin::Tuple</span>(<span class="string">"https"</span>.<span class="ident">into</span>(),
<span class="ident">Host::Domain</span>(<span class="string">"example.com"</span>.<span class="ident">into</span>()),
<span class="number">443</span>));</code></pre></div>
<p>URL with <code>file</code> scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Host</span>, <span class="ident">Origin</span>, <span class="ident">Url</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"file:///tmp/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">origin</span>().<span class="ident">is_tuple</span>());
<span class="kw">let</span> <span class="ident">other_url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"file:///tmp/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">origin</span>() <span class="op">!</span><span class="op">=</span> <span class="ident">other_url</span>.<span class="ident">origin</span>());</code></pre></div>
<p>URL with other scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Host</span>, <span class="ident">Origin</span>, <span class="ident">Url</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"foo:bar"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">origin</span>().<span class="ident">is_tuple</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.scheme" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#781-783">source</a></span><a href="#method.scheme" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.scheme" class="fnname">scheme</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Return the scheme of this URL, lower-cased, as an ASCII string without the ‘:’ delimiter.</p>
<h5 id="examples-8"><a href="#examples-8">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"file:///tmp/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">scheme</span>(), <span class="string">"file"</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.has_authority" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#811-814">source</a></span><a href="#method.has_authority" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.has_authority" class="fnname">has_authority</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Return whether the URL has an ‘authority’,
which can contain a username, password, host, and port number.</p>
<p>URLs that do <em>not</em> are either path-only like <code>unix:/run/foo.socket</code>
or cannot-be-a-base like <code>data:text/plain,Stuff</code>.</p>
<h5 id="examples-9"><a href="#examples-9">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">has_authority</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">has_authority</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">has_authority</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cannot_be_a_base" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#842-844">source</a></span><a href="#method.cannot_be_a_base" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.cannot_be_a_base" class="fnname">cannot_be_a_base</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Return whether this URL is a cannot-be-a-base URL,
meaning that parsing a relative URL string with this URL as the base will return an error.</p>
<p>This is the case if the scheme and <code>:</code> delimiter are not followed by a <code>/</code> slash,
as is typically the case of <code>data:</code> and <code>mailto:</code> URLs.</p>
<h5 id="examples-10"><a href="#examples-10">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">cannot_be_a_base</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">cannot_be_a_base</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">cannot_be_a_base</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.username" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#868-875">source</a></span><a href="#method.username" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.username" class="fnname">username</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Return the username for this URL (typically the empty string)
as a percent-encoded ASCII string.</p>
<h5 id="examples-11"><a href="#examples-11">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">username</span>(), <span class="string">"rms"</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://:secret123@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">username</span>(), <span class="string">""</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">username</span>(), <span class="string">""</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.password" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#901-913">source</a></span><a href="#method.password" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.password" class="fnname">password</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></h4></section></summary><div class="docblock"><p>Return the password for this URL, if any, as a percent-encoded ASCII string.</p>
<h5 id="examples-12"><a href="#examples-12">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://rms:secret123@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">Some</span>(<span class="string">"secret123"</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://:secret123@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">Some</span>(<span class="string">"secret123"</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.has_host" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#936-938">source</a></span><a href="#method.has_host" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.has_host" class="fnname">has_host</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Equivalent to <code>url.host().is_some()</code>.</p>
<h5 id="examples-13"><a href="#examples-13">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">has_host</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">has_host</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">has_host</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.host_str" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#973-979">source</a></span><a href="#method.host_str" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.host_str" class="fnname">host_str</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></h4></section></summary><div class="docblock"><p>Return the string representation of the host (domain or IP address) for this URL, if any.</p>
<p>Non-ASCII domains are punycode-encoded per IDNA if this is the host
of a special URL, or percent encoded for non-special URLs.
IPv6 addresses are given between <code>[</code> and <code>]</code> brackets.</p>
<p>Cannot-be-a-base URLs (typical of <code>data:</code> and <code>mailto:</code>) and some <code>file:</code> URLs
don’t have a host.</p>
<p>See also the <code>host</code> method.</p>
<h5 id="examples-14"><a href="#examples-14">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://127.0.0.1/index.html"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">Some</span>(<span class="string">"127.0.0.1"</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">Some</span>(<span class="string">"example.com"</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.host" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1012-1019">source</a></span><a href="#method.host" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.host" class="fnname">host</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="enum.Host.html" title="enum url::Host">Host</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>></h4></section></summary><div class="docblock"><p>Return the parsed representation of the host for this URL.
Non-ASCII domain labels are punycode-encoded per IDNA if this is the host
of a special URL, or percent encoded for non-special URLs.</p>
<p>Cannot-be-a-base URLs (typical of <code>data:</code> and <code>mailto:</code>) and some <code>file:</code> URLs
don’t have a host.</p>
<p>See also the <code>host_str</code> method.</p>
<h5 id="examples-15"><a href="#examples-15">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://127.0.0.1/index.html"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">host</span>().<span class="ident">is_some</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">host</span>().<span class="ident">is_some</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">host</span>().<span class="ident">is_none</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">host</span>().<span class="ident">is_none</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.domain" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1044-1049">source</a></span><a href="#method.domain" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.domain" class="fnname">domain</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></h4></section></summary><div class="docblock"><p>If this URL has a host and it is a domain name (not an IP address), return it.
Non-ASCII domains are punycode-encoded per IDNA if this is the host
of a special URL, or percent encoded for non-special URLs.</p>
<h5 id="examples-16"><a href="#examples-16">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://127.0.0.1/"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">domain</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"mailto:rms@example.net"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">domain</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">domain</span>(), <span class="prelude-val">Some</span>(<span class="string">"example.com"</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.port" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1076-1078">source</a></span><a href="#method.port" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.port" class="fnname">port</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>></h4></section></summary><div class="docblock"><p>Return the port number for this URL, if any.</p>
<p>Note that default port numbers are never reflected by the serialization,
use the <code>port_or_known_default()</code> method if you want a default port number returned.</p>
<h5 id="examples-17"><a href="#examples-17">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">port</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com:443/"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">port</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ssh://example.com:22"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">port</span>(), <span class="prelude-val">Some</span>(<span class="number">22</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.port_or_known_default" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1108-1110">source</a></span><a href="#method.port_or_known_default" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.port_or_known_default" class="fnname">port_or_known_default</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>></h4></section></summary><div class="docblock"><p>Return the port number for this URL, or the default port number if it is known.</p>
<p>This method only knows the default port number
of the <code>http</code>, <code>https</code>, <code>ws</code>, <code>wss</code> and <code>ftp</code> schemes.</p>
<p>For URLs in these schemes, this method always returns <code>Some(_)</code>.
For other schemes, it is the same as <code>Url::port()</code>.</p>
<h5 id="examples-18"><a href="#examples-18">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"foo://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">port_or_known_default</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"foo://example.com:1456"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">port_or_known_default</span>(), <span class="prelude-val">Some</span>(<span class="number">1456</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">port_or_known_default</span>(), <span class="prelude-val">Some</span>(<span class="number">443</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.socket_addrs" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1139-1165">source</a></span><a href="#method.socket_addrs" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.socket_addrs" class="fnname">socket_addrs</a>(<br> &self, <br> default_port_number: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>><br>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>>></h4></section></summary><div class="docblock"><p>Resolve a URL’s host and port number to <code>SocketAddr</code>.</p>
<p>If the URL has the default port number of a scheme that is unknown to this library,
<code>default_port_number</code> provides an opportunity to provide the actual port number.
In non-example code this should be implemented either simply as <code>|| None</code>,
or by matching on the URL’s <code>.scheme()</code>.</p>
<p>If the host is a domain, it is resolved using the standard library’s DNS support.</p>
<h5 id="examples-19"><a href="#examples-19">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">url::Url::parse</span>(<span class="string">"https://example.net/"</span>).<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">addrs</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">socket_addrs</span>(<span class="op">|</span><span class="op">|</span> <span class="prelude-val">None</span>).<span class="ident">unwrap</span>();
<span class="ident">std::net::TcpStream::connect</span>(<span class="kw-2">&</span><span class="kw-2">*</span><span class="ident">addrs</span>)</code></pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="doccomment">/// With application-specific known default port numbers</span>
<span class="kw">fn</span> <span class="ident">socket_addrs</span>(<span class="ident">url</span>: <span class="ident">url::Url</span>) -> <span class="ident">std::io::Result</span><span class="op"><</span><span class="ident">Vec</span><span class="op"><</span><span class="ident">std::net::SocketAddr</span><span class="op">></span><span class="op">></span> {
<span class="ident">url</span>.<span class="ident">socket_addrs</span>(<span class="op">|</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">url</span>.<span class="ident">scheme</span>() {
<span class="string">"socks5"</span> <span class="op">|</span> <span class="string">"socks5h"</span> => <span class="prelude-val">Some</span>(<span class="number">1080</span>),
<span class="kw">_</span> => <span class="prelude-val">None</span>,
})
}</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.path" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1190-1197">source</a></span><a href="#method.path" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.path" class="fnname">path</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Return the path for this URL, as a percent-encoded ASCII string.
For cannot-be-a-base URLs, this is an arbitrary string that doesn’t start with ‘/’.
For other URLs, this starts with a ‘/’ slash
and continues with slash-separated path segments.</p>
<h5 id="examples-20"><a href="#examples-20">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/api/versions?page=2"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">"/api/versions"</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">"/"</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/countries/việt nam"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">"/countries/vi%E1%BB%87t%20nam"</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.path_segments" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1238-1245">source</a></span><a href="#method.path_segments" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.path_segments" class="fnname">path_segments</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/str/iter/struct.Split.html" title="struct core::str::iter::Split">Split</a><'_, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.char.html">char</a>>></h4></section></summary><div class="docblock"><p>Unless this URL is cannot-be-a-base,
return an iterator of ‘/’ slash-separated path segments,
each as a percent-encoded ASCII string.</p>
<p>Return <code>None</code> for cannot-be-a-base URLs.</p>
<p>When <code>Some</code> is returned, the iterator always contains at least one string
(which may be empty).</p>
<h5 id="examples-21"><a href="#examples-21">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/foo/bar"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">path_segments</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">path_segments</span>().<span class="ident">ok_or_else</span>(<span class="op">|</span><span class="op">|</span> <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">"foo"</span>));
<span class="macro">assert_eq!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">"bar"</span>));
<span class="macro">assert_eq!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">path_segments</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">path_segments</span>().<span class="ident">ok_or_else</span>(<span class="op">|</span><span class="op">|</span> <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">""</span>));
<span class="macro">assert_eq!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"data:text/plain,HelloWorld"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">path_segments</span>().<span class="ident">is_none</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/countries/việt nam"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">path_segments</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">path_segments</span>().<span class="ident">ok_or_else</span>(<span class="op">|</span><span class="op">|</span> <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">"countries"</span>));
<span class="macro">assert_eq!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">"vi%E1%BB%87t%20nam"</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.query" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1271-1283">source</a></span><a href="#method.query" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.query" class="fnname">query</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></h4></section></summary><div class="docblock"><p>Return this URL’s query string, if any, as a percent-encoded ASCII string.</p>
<h5 id="examples-22"><a href="#examples-22">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">fn</span> <span class="ident">run</span>() -> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">ParseError</span><span class="op">></span> {
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/products?page=2"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">query</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">query</span>();
<span class="macro">assert_eq!</span>(<span class="ident">query</span>, <span class="prelude-val">Some</span>(<span class="string">"page=2"</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/products"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">query</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">query</span>();
<span class="macro">assert!</span>(<span class="ident">query</span>.<span class="ident">is_none</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/?country=español"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">query</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">query</span>();
<span class="macro">assert_eq!</span>(<span class="ident">query</span>, <span class="prelude-val">Some</span>(<span class="string">"country=espa%C3%B1ol"</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.query_pairs" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1310-1312">source</a></span><a href="#method.query_pairs" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.query_pairs" class="fnname">query_pairs</a>(&self) -> <a class="struct" href="../form_urlencoded/struct.Parse.html" title="struct form_urlencoded::Parse">Parse</a><'_></h4></section></summary><div class="docblock"><p>Parse the URL’s query string, if any, as <code>application/x-www-form-urlencoded</code>
and return an iterator of (key, value) pairs.</p>
<h5 id="examples-23"><a href="#examples-23">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">std::borrow::Cow</span>;
<span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/products?page=2&sort=desc"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">pairs</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">query_pairs</span>();
<span class="macro">assert_eq!</span>(<span class="ident">pairs</span>.<span class="ident">count</span>(), <span class="number">2</span>);
<span class="macro">assert_eq!</span>(<span class="ident">pairs</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>((<span class="ident">Cow::Borrowed</span>(<span class="string">"page"</span>), <span class="ident">Cow::Borrowed</span>(<span class="string">"2"</span>))));
<span class="macro">assert_eq!</span>(<span class="ident">pairs</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>((<span class="ident">Cow::Borrowed</span>(<span class="string">"sort"</span>), <span class="ident">Cow::Borrowed</span>(<span class="string">"desc"</span>))));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fragment" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1346-1351">source</a></span><a href="#method.fragment" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.fragment" class="fnname">fragment</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></h4></section></summary><div class="docblock"><p>Return this URL’s fragment identifier, if any.</p>
<p>A fragment is the part of the URL after the <code>#</code> symbol.
The fragment is optional and, if present, contains a fragment identifier
that identifies a secondary resource, such as a section heading
of a document.</p>
<p>In HTML, the fragment identifier is usually the id attribute of a an element
that is scrolled to on load. Browsers typically will not send the fragment portion
of a URL to the server.</p>
<p><strong>Note:</strong> the parser did <em>not</em> percent-encode this component,
but the input may have been percent-encoded already.</p>
<h5 id="examples-24"><a href="#examples-24">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/data.csv#row=4"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">fragment</span>(), <span class="prelude-val">Some</span>(<span class="string">"row=4"</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/data.csv#cell=4,1-6,2"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">fragment</span>(), <span class="prelude-val">Some</span>(<span class="string">"cell=4,1-6,2"</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_fragment" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1383-1397">source</a></span><a href="#method.set_fragment" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.set_fragment" class="fnname">set_fragment</a>(&mut self, fragment: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>)</h4></section></summary><div class="docblock"><p>Change this URL’s fragment identifier.</p>
<h5 id="examples-25"><a href="#examples-25">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/data.csv"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.com/data.csv"</span>);
<span class="ident">url</span>.<span class="ident">set_fragment</span>(<span class="prelude-val">Some</span>(<span class="string">"cell=4,1-6,2"</span>));
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.com/data.csv#cell=4,1-6,2"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">fragment</span>(), <span class="prelude-val">Some</span>(<span class="string">"cell=4,1-6,2"</span>));
<span class="ident">url</span>.<span class="ident">set_fragment</span>(<span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.com/data.csv"</span>);
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">fragment</span>().<span class="ident">is_none</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_query" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1436-1461">source</a></span><a href="#method.set_query" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.set_query" class="fnname">set_query</a>(&mut self, query: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>)</h4></section></summary><div class="docblock"><p>Change this URL’s query string.</p>
<h5 id="examples-26"><a href="#examples-26">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/products"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.com/products"</span>);
<span class="ident">url</span>.<span class="ident">set_query</span>(<span class="prelude-val">Some</span>(<span class="string">"page=2"</span>));
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.com/products?page=2"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">query</span>(), <span class="prelude-val">Some</span>(<span class="string">"page=2"</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.query_pairs_mut" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1495-1513">source</a></span><a href="#method.query_pairs_mut" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.query_pairs_mut" class="fnname">query_pairs_mut</a>(&mut self) -> <a class="struct" href="../form_urlencoded/struct.Serializer.html" title="struct form_urlencoded::Serializer">Serializer</a><'_, <a class="struct" href="struct.UrlQuery.html" title="struct url::UrlQuery">UrlQuery</a><'_>></h4></section></summary><div class="docblock"><p>Manipulate this URL’s query string, viewed as a sequence of name/value pairs
in <code>application/x-www-form-urlencoded</code> syntax.</p>
<p>The return value has a method-chaining API:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net?lang=fr#nav"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">query</span>(), <span class="prelude-val">Some</span>(<span class="string">"lang=fr"</span>));
<span class="ident">url</span>.<span class="ident">query_pairs_mut</span>().<span class="ident">append_pair</span>(<span class="string">"foo"</span>, <span class="string">"bar"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">query</span>(), <span class="prelude-val">Some</span>(<span class="string">"lang=fr&foo=bar"</span>));
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.net/?lang=fr&foo=bar#nav"</span>);
<span class="ident">url</span>.<span class="ident">query_pairs_mut</span>()
.<span class="ident">clear</span>()
.<span class="ident">append_pair</span>(<span class="string">"foo"</span>, <span class="string">"bar & baz"</span>)
.<span class="ident">append_pair</span>(<span class="string">"saisons"</span>, <span class="string">"\u{00C9}t\u{00E9}+hiver"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">query</span>(), <span class="prelude-val">Some</span>(<span class="string">"foo=bar+%26+baz&saisons=%C3%89t%C3%A9%2Bhiver"</span>));
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(),
<span class="string">"https://example.net/?foo=bar+%26+baz&saisons=%C3%89t%C3%A9%2Bhiver#nav"</span>);</code></pre></div>
<p>Note: <code>url.query_pairs_mut().clear();</code> is equivalent to <code>url.set_query(Some(""))</code>,
not <code>url.set_query(None)</code>.</p>
<p>The state of <code>Url</code> is unspecified if this return value is leaked without being dropped.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_path" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1548-1567">source</a></span><a href="#method.set_path" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.set_path" class="fnname">set_path</a>(&mut self, path: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>)</h4></section></summary><div class="docblock"><p>Change this URL’s path.</p>
<h5 id="examples-27"><a href="#examples-27">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_path</span>(<span class="string">"api/comments"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.com/api/comments"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">"/api/comments"</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.com/api"</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_path</span>(<span class="string">"data/report.csv"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.com/data/report.csv"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">"/data/report.csv"</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.path_segments_mut" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1573-1579">source</a></span><a href="#method.path_segments_mut" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.path_segments_mut" class="fnname">path_segments_mut</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.PathSegmentsMut.html" title="struct url::PathSegmentsMut">PathSegmentsMut</a><'_>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Return an object with methods to manipulate this URL’s path segments.</p>
<p>Return <code>Err(())</code> if this URL is cannot-be-a-base.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_port" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1657-1667">source</a></span><a href="#method.set_port" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.set_port" class="fnname">set_port</a>(&mut self, port: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Change this URL’s port number.</p>
<p>Note that default port numbers are not reflected in the serialization.</p>
<p>If this URL is cannot-be-a-base, does not have a host, or has the <code>file</code> scheme;
do nothing and return <code>Err</code>.</p>
<h5 id="examples-28"><a href="#examples-28">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ssh://example.net:2048/"</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">Some</span>(<span class="number">4096</span>)).<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"ssh://example.net:4096/"</span>);
<span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">None</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"ssh://example.net/"</span>);</code></pre></div>
<p>Known default port numbers are not reflected:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.org/"</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">Some</span>(<span class="number">443</span>)).<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">port</span>().<span class="ident">is_none</span>());</code></pre></div>
<p>Cannot set port for cannot-be-a-base URLs:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"mailto:rms@example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">Some</span>(<span class="number">80</span>));
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">None</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_host" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1790-1845">source</a></span><a href="#method.set_host" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.set_host" class="fnname">set_host</a>(&mut self, host: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>></h4></section></summary><div class="docblock"><p>Change this URL’s host.</p>
<p>Removing the host (calling this with <code>None</code>)
will also remove any username, password, and port number.</p>
<h5 id="examples-29"><a href="#examples-29">Examples</a></h5>
<p>Change host:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">Some</span>(<span class="string">"rust-lang.org"</span>));
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://rust-lang.org/"</span>);</code></pre></div>
<p>Remove host:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"foo://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">None</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"foo:/"</span>);</code></pre></div>
<p>Cannot remove host for ‘special’ schemes (e.g. <code>http</code>):</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">None</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.net/"</span>);</code></pre></div>
<p>Cannot change or remove host for cannot-be-a-base URLs:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"mailto:rms@example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">Some</span>(<span class="string">"rust-lang.org"</span>));
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"mailto:rms@example.net"</span>);
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">None</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"mailto:rms@example.net"</span>);</code></pre></div>
<h5 id="errors-4"><a href="#errors-4">Errors</a></h5>
<p>If this URL is cannot-be-a-base or there is an error parsing the given <code>host</code>,
a <a href="enum.ParseError.html"><code>ParseError</code></a> variant will be returned.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_ip_host" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1928-1939">source</a></span><a href="#method.set_ip_host" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.set_ip_host" class="fnname">set_ip_host</a>(&mut self, address: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/ip/enum.IpAddr.html" title="enum std::net::ip::IpAddr">IpAddr</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Change this URL’s host to the given IP address.</p>
<p>If this URL is cannot-be-a-base, do nothing and return <code>Err</code>.</p>
<p>Compared to <code>Url::set_host</code>, this skips the host parser.</p>
<h5 id="examples-30"><a href="#examples-30">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"http://example.com"</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_ip_host</span>(<span class="string">"127.0.0.1"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>());
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">Some</span>(<span class="string">"127.0.0.1"</span>));
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"http://127.0.0.1/"</span>);</code></pre></div>
<p>Cannot change URL’s from mailto(cannot-be-base) to ip:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"mailto:rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_ip_host</span>(<span class="string">"127.0.0.1"</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>());
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"mailto:rms@example.com"</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_password" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#1968-2023">source</a></span><a href="#method.set_password" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.set_password" class="fnname">set_password</a>(&mut self, password: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Change this URL’s password.</p>
<p>If this URL is cannot-be-a-base or does not have a host, do nothing and return <code>Err</code>.</p>
<h5 id="examples-31"><a href="#examples-31">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"mailto:rmz@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_password</span>(<span class="prelude-val">Some</span>(<span class="string">"secret_password"</span>));
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://user1:secret1@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_password</span>(<span class="prelude-val">Some</span>(<span class="string">"secret_password"</span>));
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">Some</span>(<span class="string">"secret_password"</span>));
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://user2:@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_password</span>(<span class="prelude-val">Some</span>(<span class="string">"secret2"</span>));
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">Some</span>(<span class="string">"secret2"</span>));</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_username" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2061-2110">source</a></span><a href="#method.set_username" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.set_username" class="fnname">set_username</a>(&mut self, username: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Change this URL’s username.</p>
<p>If this URL is cannot-be-a-base or does not have a host, do nothing and return <code>Err</code>.</p>
<h5 id="examples-32"><a href="#examples-32">Examples</a></h5>
<p>Cannot setup username from mailto(cannot-be-base)</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"mailto:rmz@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_username</span>(<span class="string">"user1"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"mailto:rmz@example.com"</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</code></pre></div>
<p>Setup username to user1</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"ftp://:secre1@example.com/"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_username</span>(<span class="string">"user1"</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">username</span>(), <span class="string">"user1"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"ftp://user1:secre1@example.com/"</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.set_scheme" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2223-2272">source</a></span><a href="#method.set_scheme" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.set_scheme" class="fnname">set_scheme</a>(&mut self, scheme: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Change this URL’s scheme.</p>
<p>Do nothing and return <code>Err</code> under the following circumstances:</p>
<ul>
<li>If the new scheme is not in <code>[a-zA-Z][a-zA-Z0-9+.-]+</code></li>
<li>If this URL is cannot-be-a-base and the new scheme is one of
<code>http</code>, <code>https</code>, <code>ws</code>, <code>wss</code> or <code>ftp</code></li>
<li>If either the old or new scheme is <code>http</code>, <code>https</code>, <code>ws</code>,
<code>wss</code> or <code>ftp</code> and the other is not one of these</li>
<li>If the new scheme is <code>file</code> and this URL includes credentials
or has a non-null port</li>
<li>If this URL’s scheme is <code>file</code> and its host is empty or null</li>
</ul>
<p>See also <a href="https://url.spec.whatwg.org/#scheme-state">the URL specification’s section on legal scheme state
overrides</a>.</p>
<h5 id="examples-33"><a href="#examples-33">Examples</a></h5>
<p>Change the URL’s scheme from <code>https</code> to <code>foo</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">"http"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"http://example.net/"</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());</code></pre></div>
<p>Change the URL’s scheme from <code>foo</code> to <code>bar</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"foo://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">"bar"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"bar://example.net"</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());</code></pre></div>
<p>Cannot change URL’s scheme from <code>https</code> to <code>foõ</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">"foõ"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"https://example.net/"</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</code></pre></div>
<p>Cannot change URL’s scheme from <code>mailto</code> (cannot-be-a-base) to <code>https</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"mailto:rms@example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">"https"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"mailto:rms@example.net"</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</code></pre></div>
<p>Cannot change the URL’s scheme from <code>foo</code> to <code>https</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"foo://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">"https"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"foo://example.net"</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</code></pre></div>
<p>Cannot change the URL’s scheme from <code>http</code> to <code>foo</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::parse</span>(<span class="string">"http://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">"foo"</span>);
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"http://example.net/"</span>);
<span class="macro">assert!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_file_path" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2303-2319">source</a></span><a href="#method.from_file_path" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.from_file_path" class="fnname">from_file_path</a><P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>>(path: P) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Convert a file name as <code>std::path::Path</code> into an URL in the <code>file</code> scheme.</p>
<p>This returns <code>Err</code> if the given path is not absolute or,
on Windows, if the prefix is not a disk prefix (e.g. <code>C:</code>) or a UNC prefix (<code>\\</code>).</p>
<h5 id="examples-34"><a href="#examples-34">Examples</a></h5>
<p>On Unix-like platforms:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">url::Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::from_file_path</span>(<span class="string">"/tmp/foo.txt"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">"file:///tmp/foo.txt"</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::from_file_path</span>(<span class="string">"../foo.txt"</span>);
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">is_err</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url::from_file_path</span>(<span class="string">"https://google.com/"</span>);
<span class="macro">assert!</span>(<span class="ident">url</span>.<span class="ident">is_err</span>());</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_directory_path" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2340-2346">source</a></span><a href="#method.from_directory_path" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.from_directory_path" class="fnname">from_directory_path</a><P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>>(path: P) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Convert a directory name as <code>std::path::Path</code> into an URL in the <code>file</code> scheme.</p>
<p>This returns <code>Err</code> if the given path is not absolute or,
on Windows, if the prefix is not a disk prefix (e.g. <code>C:</code>) or a UNC prefix (<code>\\</code>).</p>
<p>Compared to <code>from_file_path</code>, this ensure that URL’s the path has a trailing slash
so that the entire path is considered when using this URL as a base URL.</p>
<p>For example:</p>
<ul>
<li><code>"index.html"</code> parsed with <code>Url::from_directory_path(Path::new("/var/www"))</code>
as the base URL is <code>file:///var/www/index.html</code></li>
<li><code>"index.html"</code> parsed with <code>Url::from_file_path(Path::new("/var/www"))</code>
as the base URL is <code>file:///var/index.html</code>, which might not be what was intended.</li>
</ul>
<p>Note that <code>std::path</code> does not consider trailing slashes significant
and usually does not include them (e.g. in <code>Path::parent()</code>).</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_file_path" class="method has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2457-2470">source</a></span><a href="#method.to_file_path" class="anchor"></a><h4 class="code-header">pub fn <a href="#method.to_file_path" class="fnname">to_file_path</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Assuming the URL is in the <code>file</code> scheme or similar,
convert its path to an absolute <code>std::path::Path</code>.</p>
<p><strong>Note:</strong> This does not actually check the URL’s <code>scheme</code>,
and may give nonsensical results for other schemes.
It is the user’s responsibility to check the URL’s scheme before calling this.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let</span> <span class="ident">path</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">to_file_path</span>();</code></pre></div>
<p>Returns <code>Err</code> if the host is neither empty nor <code>"localhost"</code> (except on Windows, where
<code>file:</code> URLs may have a non-local host),
or if <code>Path::new_opt()</code> returns <code>None</code>.
(That is, if the percent-decoded path contains a NUL byte or,
for a Windows path, is not UTF-8.)</p>
</div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-AsRef%3Cstr%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2579-2584">source</a></span><a href="#impl-AsRef%3Cstr%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>Return the serialization of this URL.</p>
</div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.as_ref" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2581-2583">source</a></span><a href="#method.as_ref" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'><p>Converts this type into a shared reference of the (usually inferred) input type.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Clone" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#165">source</a></span><a href="#impl-Clone" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#165">source</a></span><a href="#method.clone" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&self) -> <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h4></section></summary><div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#132-134">source</a></span><a href="#method.clone_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</h4></section></summary><div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2522-2538">source</a></span><a href="#impl-Debug" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>Debug the serialization of this URL.</p>
</div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt-1" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2524-2537">source</a></span><a href="#method.fmt-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, formatter: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Display" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2507-2512">source</a></span><a href="#impl-Display" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>Display the serialization of this URL.</p>
</div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2509-2511">source</a></span><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&self, formatter: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-From%3CUrl%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2515-2519">source</a></span><a href="#impl-From%3CUrl%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h3></section></summary><div class="docblock"><p>String converstion.</p>
</div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2516-2518">source</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(value: <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class='docblock'><p>Converts to this type from the input type.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-FromStr" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2489-2496">source</a></span><a href="#impl-FromStr" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/str/traits/trait.FromStr.html" title="trait core::str::traits::FromStr">FromStr</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>Parse a string as an URL, without a base URL or encoding override.</p>
</div><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Err" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Err" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/str/traits/trait.FromStr.html#associatedtype.Err" class="associatedtype">Err</a> = <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a></h4></section></summary><div class='docblock'><p>The associated error which can be returned from parsing.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from_str" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2493-2495">source</a></span><a href="#method.from_str" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/str/traits/trait.FromStr.html#tymethod.from_str" class="fnname">from_str</a>(input: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>></h4></section></summary><div class='docblock'><p>Parses a string <code>s</code> to return a value of this type. <a href="https://doc.rust-lang.org/nightly/core/str/traits/trait.FromStr.html#tymethod.from_str">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Hash" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2568-2576">source</a></span><a href="#impl-Hash" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>URLs hash like their serialization.</p>
</div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2570-2575">source</a></span><a href="#method.hash" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash" class="fnname">hash</a><H>(&self, state: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>H) <span class="where fmt-newline">where<br> H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>, </span></h4></section></summary><div class='docblock'><p>Feeds this value into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/hash/mod.rs.html#237-239">source</a></span><a href="#method.hash_slice" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice" class="fnname">hash_slice</a><H>(data: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>H) <span class="where fmt-newline">where<br> H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>, </span></h4></section></summary><div class='docblock'><p>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Index%3CRange%3CPosition%3E%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/slicing.rs.html#33-38">source</a></span><a href="#impl-Index%3CRange%3CPosition%3E%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a><<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>>> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-3" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-3" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'><p>The returned type after indexing.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.index-3" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/slicing.rs.html#35-37">source</a></span><a href="#method.index-3" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index" class="fnname">index</a>(&self, range: <a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a><<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>>) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'><p>Performs the indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Index%3CRangeFrom%3CPosition%3E%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/slicing.rs.html#19-24">source</a></span><a href="#impl-Index%3CRangeFrom%3CPosition%3E%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeFrom.html" title="struct core::ops::range::RangeFrom">RangeFrom</a><<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>>> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-1" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'><p>The returned type after indexing.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.index-1" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/slicing.rs.html#21-23">source</a></span><a href="#method.index-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index" class="fnname">index</a>(&self, range: <a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeFrom.html" title="struct core::ops::range::RangeFrom">RangeFrom</a><<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>>) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'><p>Performs the indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Index%3CRangeFull%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/slicing.rs.html#12-17">source</a></span><a href="#impl-Index%3CRangeFull%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeFull.html" title="struct core::ops::range::RangeFull">RangeFull</a>> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'><p>The returned type after indexing.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.index" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/slicing.rs.html#14-16">source</a></span><a href="#method.index" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index" class="fnname">index</a>(&self, _: <a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeFull.html" title="struct core::ops::range::RangeFull">RangeFull</a>) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'><p>Performs the indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Index%3CRangeTo%3CPosition%3E%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/slicing.rs.html#26-31">source</a></span><a href="#impl-Index%3CRangeTo%3CPosition%3E%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a><<a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeTo.html" title="struct core::ops::range::RangeTo">RangeTo</a><<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>>> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Output-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Output-2" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'><p>The returned type after indexing.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.index-2" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/slicing.rs.html#28-30">source</a></span><a href="#method.index-2" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index" class="fnname">index</a>(&self, range: <a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeTo.html" title="struct core::ops::range::RangeTo">RangeTo</a><<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>>) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'><p>Performs the indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Ord" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2552-2557">source</a></span><a href="#impl-Ord" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.cmp" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2554-2556">source</a></span><a href="#method.cmp" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp" class="fnname">cmp</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></h4></section></summary><div class='docblock'><p>This method returns an <a href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="Ordering"><code>Ordering</code></a> between <code>self</code> and <code>other</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.max" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#796-798">source</a></span><a href="#method.max" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.max" class="fnname">max</a>(self, other: Self) -> Self</h4></section></summary><div class='docblock'><p>Compares and returns the maximum of two values. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.max">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.min" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#816-818">source</a></span><a href="#method.min" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.min" class="fnname">min</a>(self, other: Self) -> Self</h4></section></summary><div class='docblock'><p>Compares and returns the minimum of two values. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.min">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clamp" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.50.0">1.50.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#841-843">source</a></span><a href="#method.clamp" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.clamp" class="fnname">clamp</a>(self, min: Self, max: Self) -> Self</h4></section></summary><div class='docblock'><p>Restrict a value to a certain interval. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.clamp">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CUrl%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2544-2549">source</a></span><a href="#impl-PartialEq%3CUrl%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2546-2548">source</a></span><a href="#method.eq" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#230">source</a></span><a href="#method.ne" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'><p>This method tests for <code>!=</code>.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-PartialOrd%3CUrl%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2560-2565">source</a></span><a href="#impl-PartialOrd%3CUrl%3E" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a><<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.partial_cmp" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2562-2564">source</a></span><a href="#method.partial_cmp" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp" class="fnname">partial_cmp</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>></h4></section></summary><div class='docblock'><p>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.lt" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#1100">source</a></span><a href="#method.lt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt" class="fnname">lt</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.le" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#1119">source</a></span><a href="#method.le" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le" class="fnname">le</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'><p>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code>
operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.gt" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#1141">source</a></span><a href="#method.gt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt" class="fnname">gt</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.ge" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#1160">source</a></span><a href="#method.ge" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge" class="fnname">ge</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Rhs) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'><p>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code>
operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-TryFrom%3C%26%27a%20str%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2498-2504">source</a></span><a href="#impl-TryFrom%3C%26%27a%20str%3E" class="anchor"></a><h3 class="code-header in-band">impl<'a> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><&'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a></h4></section></summary><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2501-2503">source</a></span><a href="#method.try_from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(s: &'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, Self::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'><p>Performs the conversion.</p>
</div></details></div></details><section id="impl-Eq" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/url/lib.rs.html#2541">source</a></span><a href="#impl-Eq" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><div class="docblock"><p>URLs compare like their serialization.</p>
</div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe" class="impl has-srclink"><a href="#impl-RefUnwindSafe" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><section id="impl-Send" class="impl has-srclink"><a href="#impl-Send" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><section id="impl-Sync" class="impl has-srclink"><a href="#impl-Sync" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><section id="impl-Unpin" class="impl has-srclink"><a href="#impl-Unpin" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><section id="impl-UnwindSafe" class="impl has-srclink"><a href="#impl-UnwindSafe" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#203">source</a></span><a href="#impl-Any" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#204">source</a></span><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#209">source</a></span><a href="#impl-Borrow%3CT%3E" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#211">source</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T</h4></section></summary><div class='docblock'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#218">source</a></span><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#219">source</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T</h4></section></summary><div class='docblock'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#557">source</a></span><a href="#impl-From%3CT%3E" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#559">source</a></span><a href="#method.from-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#541">source</a></span><a href="#impl-Into%3CU%3E" class="anchor"></a><h3 class="code-header in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>, </span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#549">source</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="From">From</a><T> for U</code> chooses to do.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToOwned" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#83">source</a></span><a href="#impl-ToOwned" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>, </span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Owned" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'><p>The resulting type after obtaining ownership.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#88">source</a></span><a href="#method.to_owned" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#92">source</a></span><a href="#method.clone_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T)</h4></section></summary><div class='docblock'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ToString" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2479">source</a></span><a href="#impl-ToString" class="anchor"></a><h3 class="code-header in-band">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.to_string" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2485">source</a></span><a href="#method.to_string" class="anchor"></a><h4 class="code-header">default fn <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string" class="fnname">to_string</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class='docblock'><p>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string">Read more</a></p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#598">source</a></span><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><h3 class="code-header in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-2" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_from-1" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#604">source</a></span><a href="#method.try_from-1" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'><p>Performs the conversion.</p>
</div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#583">source</a></span><a href="#impl-TryInto%3CU%3E" class="anchor"></a><h3 class="code-header in-band">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#589">source</a></span><a href="#method.try_into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'><p>Performs the conversion.</p>
</div></details></div></details></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="url" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0-nightly (495b21669 2022-07-03)" ></div>
</body></html>