@@ -47,6 +47,7 @@ assert!(issue_list_url.fragment() == None);
47
47
assert!(!issue_list_url.cannot_be_a_base());
48
48
# Ok(())
49
49
# }
50
+ # run().unwrap();
50
51
```
51
52
52
53
Some URLs are said to be *cannot-be-a-base*:
@@ -68,6 +69,7 @@ assert!(data_url.query() == Some("World"));
68
69
assert!(data_url.fragment() == Some(""));
69
70
# Ok(())
70
71
# }
72
+ # run().unwrap();
71
73
```
72
74
73
75
@@ -99,6 +101,7 @@ let css_url = this_document.join("../main.css")?;
99
101
assert_eq!(css_url.as_str(), "http://servo.github.io/rust-url/main.css");
100
102
# Ok(())
101
103
# }
104
+ # run().unwrap();
102
105
*/
103
106
104
107
#[ cfg( feature="rustc-serialize" ) ] extern crate rustc_serialize;
@@ -235,6 +238,7 @@ impl Url {
235
238
/// let url = Url::parse("https://example.net")?;
236
239
/// # Ok(())
237
240
/// # }
241
+ /// # run().unwrap();
238
242
/// ```
239
243
#[ inline]
240
244
pub fn parse ( input : & str ) -> Result < Url , :: ParseError > {
@@ -256,6 +260,7 @@ impl Url {
256
260
/// &[("lang", "rust"), ("browser", "servo")])?;
257
261
/// # Ok(())
258
262
/// # }
263
+ /// # run().unwrap();
259
264
/// ```
260
265
#[ inline]
261
266
pub fn parse_with_params < I , K , V > ( input : & str , iter : I ) -> Result < Url , :: ParseError >
@@ -295,6 +300,7 @@ impl Url {
295
300
/// assert_eq!(url.as_str(), "https://example.net/a/b/c.png");
296
301
/// # Ok(())
297
302
/// # }
303
+ /// # run().unwrap();
298
304
/// ```
299
305
#[ inline]
300
306
pub fn join ( & self , input : & str ) -> Result < Url , :: ParseError > {
@@ -326,6 +332,7 @@ impl Url {
326
332
/// assert_eq!(url.as_str(), url_str);
327
333
/// # Ok(())
328
334
/// # }
335
+ /// # run().unwrap();
329
336
/// ```
330
337
#[ inline]
331
338
pub fn as_str ( & self ) -> & str {
@@ -348,6 +355,7 @@ impl Url {
348
355
/// assert_eq!(url.into_string(), url_str);
349
356
/// # Ok(())
350
357
/// # }
358
+ /// # run().unwrap();
351
359
/// ```
352
360
#[ inline]
353
361
pub fn into_string ( self ) -> String {
@@ -483,6 +491,7 @@ impl Url {
483
491
/// 21));
484
492
/// # Ok(())
485
493
/// # }
494
+ /// # run().unwrap();
486
495
/// ```
487
496
///
488
497
/// URL with `blob` scheme:
@@ -499,6 +508,7 @@ impl Url {
499
508
/// 443));
500
509
/// # Ok(())
501
510
/// # }
511
+ /// # run().unwrap();
502
512
/// ```
503
513
///
504
514
/// URL with `file` scheme:
@@ -515,6 +525,7 @@ impl Url {
515
525
/// assert!(url.origin() != other_url.origin());
516
526
/// # Ok(())
517
527
/// # }
528
+ /// # run().unwrap();
518
529
/// ```
519
530
///
520
531
/// URL with other scheme:
@@ -528,6 +539,7 @@ impl Url {
528
539
/// assert!(!url.origin().is_tuple());
529
540
/// # Ok(())
530
541
/// # }
542
+ /// # run().unwrap();
531
543
/// ```
532
544
#[ inline]
533
545
pub fn origin ( & self ) -> Origin {
@@ -547,6 +559,7 @@ impl Url {
547
559
/// assert_eq!(url.scheme(), "file");
548
560
/// # Ok(())
549
561
/// # }
562
+ /// # run().unwrap();
550
563
/// ```
551
564
#[ inline]
552
565
pub fn scheme ( & self ) -> & str {
@@ -576,6 +589,7 @@ impl Url {
576
589
/// assert!(!url.has_authority());
577
590
/// # Ok(())
578
591
/// # }
592
+ /// # run().unwrap();
579
593
/// ```
580
594
#[ inline]
581
595
pub fn has_authority ( & self ) -> bool {
@@ -606,6 +620,7 @@ impl Url {
606
620
/// assert!(url.cannot_be_a_base());
607
621
/// # Ok(())
608
622
/// # }
623
+ /// # run().unwrap();
609
624
/// ```
610
625
#[ inline]
611
626
pub fn cannot_be_a_base ( & self ) -> bool {
@@ -632,6 +647,7 @@ impl Url {
632
647
/// assert_eq!(url.username(), "");
633
648
/// # Ok(())
634
649
/// # }
650
+ /// # run().unwrap();
635
651
/// ```
636
652
pub fn username ( & self ) -> & str {
637
653
if self . has_authority ( ) {
@@ -663,6 +679,7 @@ impl Url {
663
679
/// assert_eq!(url.password(), None);
664
680
/// # Ok(())
665
681
/// # }
682
+ /// # run().unwrap();
666
683
/// ```
667
684
pub fn password ( & self ) -> Option < & str > {
668
685
// This ':' is not the one marking a port number since a host can not be empty.
@@ -694,6 +711,7 @@ impl Url {
694
711
/// assert!(!url.has_host());
695
712
/// # Ok(())
696
713
/// # }
714
+ /// # run().unwrap();
697
715
/// ```
698
716
pub fn has_host ( & self ) -> bool {
699
717
!matches ! ( self . host, HostInternal :: None )
@@ -729,6 +747,7 @@ impl Url {
729
747
/// assert_eq!(url.host_str(), None);
730
748
/// # Ok(())
731
749
/// # }
750
+ /// # run().unwrap();
732
751
/// ```
733
752
pub fn host_str ( & self ) -> Option < & str > {
734
753
if self . has_host ( ) {
@@ -766,6 +785,7 @@ impl Url {
766
785
/// assert!(url.host().is_none());
767
786
/// # Ok(())
768
787
/// # }
788
+ /// # run().unwrap();
769
789
/// ```
770
790
pub fn host ( & self ) -> Option < Host < & str > > {
771
791
match self . host {
@@ -795,6 +815,7 @@ impl Url {
795
815
/// assert_eq!(url.domain(), Some("example.com"));
796
816
/// # Ok(())
797
817
/// # }
818
+ /// # run().unwrap();
798
819
/// ```
799
820
pub fn domain ( & self ) -> Option < & str > {
800
821
match self . host {
@@ -819,6 +840,7 @@ impl Url {
819
840
/// assert_eq!(url.port(), Some(22));
820
841
/// # Ok(())
821
842
/// # }
843
+ /// # run().unwrap();
822
844
/// ```
823
845
#[ inline]
824
846
pub fn port ( & self ) -> Option < u16 > {
@@ -850,6 +872,7 @@ impl Url {
850
872
/// assert_eq!(url.port_or_known_default(), Some(443));
851
873
/// # Ok(())
852
874
/// # }
875
+ /// # run().unwrap();
853
876
/// ```
854
877
#[ inline]
855
878
pub fn port_or_known_default ( & self ) -> Option < u16 > {
@@ -942,6 +965,7 @@ impl Url {
942
965
/// assert!(url.path_segments().is_none());
943
966
/// # Ok(())
944
967
/// # }
968
+ /// # run().unwrap();
945
969
/// ```
946
970
pub fn path_segments ( & self ) -> Option < str:: Split < char > > {
947
971
let path = self . path ( ) ;
@@ -1072,6 +1096,7 @@ impl Url {
1072
1096
/// "https://example.net/?foo=bar+%26+baz&saisons=%C3%89t%C3%A9%2Bhiver#nav");
1073
1097
/// # Ok(())
1074
1098
/// # }
1099
+ /// # run().unwrap();
1075
1100
/// ```
1076
1101
///
1077
1102
/// Note: `url.query_pairs_mut().clear();` is equivalent to `url.set_query(Some(""))`,
@@ -1171,6 +1196,7 @@ impl Url {
1171
1196
/// assert_eq!(url.as_str(), "ssh://example.net/");
1172
1197
/// # Ok(())
1173
1198
/// # }
1199
+ /// # run().unwrap();
1174
1200
/// ```
1175
1201
///
1176
1202
/// Cannot set port for cannot-be-a-base URLs:
@@ -1189,6 +1215,7 @@ impl Url {
1189
1215
/// assert!(result.is_err());
1190
1216
/// # Ok(())
1191
1217
/// # }
1218
+ /// # run().unwrap();
1192
1219
/// ```
1193
1220
pub fn set_port ( & mut self , mut port : Option < u16 > ) -> Result < ( ) , ( ) > {
1194
1221
if !self . has_host ( ) || self . scheme ( ) == "file" {
@@ -1254,6 +1281,7 @@ impl Url {
1254
1281
/// assert_eq!(url.as_str(), "https://rust-lang.org/");
1255
1282
/// # Ok(())
1256
1283
/// # }
1284
+ /// # run().unwrap();
1257
1285
/// ```
1258
1286
///
1259
1287
/// Remove host:
@@ -1269,6 +1297,7 @@ impl Url {
1269
1297
/// assert_eq!(url.as_str(), "foo:/");
1270
1298
/// # Ok(())
1271
1299
/// # }
1300
+ /// # run().unwrap();
1272
1301
/// ```
1273
1302
///
1274
1303
/// Cannot remove host for 'special' schemes (e.g. `http`):
@@ -1284,6 +1313,7 @@ impl Url {
1284
1313
/// assert_eq!(url.as_str(), "https://example.net/");
1285
1314
/// # Ok(())
1286
1315
/// # }
1316
+ /// # run().unwrap();
1287
1317
/// ```
1288
1318
///
1289
1319
/// Cannot change or remove host for cannot-be-a-base URLs:
@@ -1304,6 +1334,7 @@ impl Url {
1304
1334
/// assert_eq!(url.as_str(), "mailto:[email protected] ");
1305
1335
/// # Ok(())
1306
1336
/// # }
1337
+ /// # run().unwrap();
1307
1338
/// ```
1308
1339
pub fn set_host ( & mut self , host : Option < & str > ) -> Result < ( ) , ParseError > {
1309
1340
if self . cannot_be_a_base ( ) {
@@ -1507,6 +1538,7 @@ impl Url {
1507
1538
/// assert!(result.is_ok());
1508
1539
/// # Ok(())
1509
1540
/// # }
1541
+ /// # run().unwrap();
1510
1542
/// ```
1511
1543
///
1512
1544
///
@@ -1523,6 +1555,7 @@ impl Url {
1523
1555
/// assert!(result.is_err());
1524
1556
/// # Ok(())
1525
1557
/// # }
1558
+ /// # run().unwrap();
1526
1559
/// ```
1527
1560
///
1528
1561
/// Cannot change URL’s scheme from `mailto` (cannot-be-a-base) to `https`:
@@ -1538,6 +1571,7 @@ impl Url {
1538
1571
/// assert!(result.is_err());
1539
1572
/// # Ok(())
1540
1573
/// # }
1574
+ /// # run().unwrap();
1541
1575
/// ```
1542
1576
pub fn set_scheme ( & mut self , scheme : & str ) -> Result < ( ) , ( ) > {
1543
1577
let mut parser = Parser :: for_setter ( String :: new ( ) ) ;
@@ -1590,6 +1624,7 @@ impl Url {
1590
1624
/// assert!(url.is_err());
1591
1625
/// # Ok(())
1592
1626
/// # }
1627
+ /// # run().unwrap();
1593
1628
/// # }
1594
1629
/// ```
1595
1630
pub fn from_file_path < P : AsRef < Path > > ( path : P ) -> Result < Url , ( ) > {
0 commit comments