@@ -1352,17 +1352,21 @@ pub trait StrPrelude for Sized? {
1352
1352
/// # Example
1353
1353
///
1354
1354
/// ```rust
1355
+ /// # #![feature(unboxed_closures)]
1356
+ ///
1357
+ /// # fn main() {
1355
1358
/// let v: Vec<&str> = "Mary had a little lamb".split(' ').collect();
1356
1359
/// assert_eq!(v, vec!["Mary", "had", "a", "little", "lamb"]);
1357
1360
///
1358
- /// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).collect();
1361
+ /// let v: Vec<&str> = "abc1def2ghi".split(|&: c: char| c.is_numeric()).collect();
1359
1362
/// assert_eq!(v, vec!["abc", "def", "ghi"]);
1360
1363
///
1361
1364
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').collect();
1362
1365
/// assert_eq!(v, vec!["lion", "", "tiger", "leopard"]);
1363
1366
///
1364
1367
/// let v: Vec<&str> = "".split('X').collect();
1365
1368
/// assert_eq!(v, vec![""]);
1369
+ /// # }
1366
1370
/// ```
1367
1371
fn split < ' a , Sep : CharEq > ( & ' a self , sep : Sep ) -> CharSplits < ' a , Sep > ;
1368
1372
@@ -1373,10 +1377,13 @@ pub trait StrPrelude for Sized? {
1373
1377
/// # Example
1374
1378
///
1375
1379
/// ```rust
1380
+ /// # #![feature(unboxed_closures)]
1381
+ ///
1382
+ /// # fn main() {
1376
1383
/// let v: Vec<&str> = "Mary had a little lambda".splitn(2, ' ').collect();
1377
1384
/// assert_eq!(v, vec!["Mary", "had", "a little lambda"]);
1378
1385
///
1379
- /// let v: Vec<&str> = "abc1def2ghi".splitn(1, |c: char| c.is_numeric()).collect();
1386
+ /// let v: Vec<&str> = "abc1def2ghi".splitn(1, |&: c: char| c.is_numeric()).collect();
1380
1387
/// assert_eq!(v, vec!["abc", "def2ghi"]);
1381
1388
///
1382
1389
/// let v: Vec<&str> = "lionXXtigerXleopard".splitn(2, 'X').collect();
@@ -1387,6 +1394,7 @@ pub trait StrPrelude for Sized? {
1387
1394
///
1388
1395
/// let v: Vec<&str> = "".splitn(1, 'X').collect();
1389
1396
/// assert_eq!(v, vec![""]);
1397
+ /// # }
1390
1398
/// ```
1391
1399
fn splitn < ' a , Sep : CharEq > ( & ' a self , count : uint , sep : Sep ) -> CharSplitsN < ' a , Sep > ;
1392
1400
@@ -1399,6 +1407,9 @@ pub trait StrPrelude for Sized? {
1399
1407
/// # Example
1400
1408
///
1401
1409
/// ```rust
1410
+ /// # #![feature(unboxed_closures)]
1411
+ ///
1412
+ /// # fn main() {
1402
1413
/// let v: Vec<&str> = "A.B.".split_terminator('.').collect();
1403
1414
/// assert_eq!(v, vec!["A", "B"]);
1404
1415
///
@@ -1408,11 +1419,12 @@ pub trait StrPrelude for Sized? {
1408
1419
/// let v: Vec<&str> = "Mary had a little lamb".split(' ').rev().collect();
1409
1420
/// assert_eq!(v, vec!["lamb", "little", "a", "had", "Mary"]);
1410
1421
///
1411
- /// let v: Vec<&str> = "abc1def2ghi".split(|c: char| c.is_numeric()).rev().collect();
1422
+ /// let v: Vec<&str> = "abc1def2ghi".split(|&: c: char| c.is_numeric()).rev().collect();
1412
1423
/// assert_eq!(v, vec!["ghi", "def", "abc"]);
1413
1424
///
1414
1425
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').rev().collect();
1415
1426
/// assert_eq!(v, vec!["leopard", "tiger", "", "lion"]);
1427
+ /// # }
1416
1428
/// ```
1417
1429
fn split_terminator < ' a , Sep : CharEq > ( & ' a self , sep : Sep ) -> CharSplits < ' a , Sep > ;
1418
1430
@@ -1423,14 +1435,18 @@ pub trait StrPrelude for Sized? {
1423
1435
/// # Example
1424
1436
///
1425
1437
/// ```rust
1438
+ /// # #![feature(unboxed_closures)]
1439
+ ///
1440
+ /// # fn main() {
1426
1441
/// let v: Vec<&str> = "Mary had a little lamb".rsplitn(2, ' ').collect();
1427
1442
/// assert_eq!(v, vec!["lamb", "little", "Mary had a"]);
1428
1443
///
1429
- /// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |c: char| c.is_numeric()).collect();
1444
+ /// let v: Vec<&str> = "abc1def2ghi".rsplitn(1, |&: c: char| c.is_numeric()).collect();
1430
1445
/// assert_eq!(v, vec!["ghi", "abc1def"]);
1431
1446
///
1432
1447
/// let v: Vec<&str> = "lionXXtigerXleopard".rsplitn(2, 'X').collect();
1433
1448
/// assert_eq!(v, vec!["leopard", "tiger", "lionX"]);
1449
+ /// # }
1434
1450
/// ```
1435
1451
fn rsplitn < ' a , Sep : CharEq > ( & ' a self , count : uint , sep : Sep ) -> CharSplitsN < ' a , Sep > ;
1436
1452
@@ -1641,10 +1657,14 @@ pub trait StrPrelude for Sized? {
1641
1657
/// # Example
1642
1658
///
1643
1659
/// ```rust
1660
+ /// # #![feature(unboxed_closures)]
1661
+ ///
1662
+ /// # fn main() {
1644
1663
/// assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar")
1645
1664
/// let x: &[_] = &['1', '2'];
1646
1665
/// assert_eq!("12foo1bar12".trim_chars(x), "foo1bar")
1647
- /// assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_numeric()), "foo1bar")
1666
+ /// assert_eq!("123foo1bar123".trim_chars(|&: c: char| c.is_numeric()), "foo1bar")
1667
+ /// # }
1648
1668
/// ```
1649
1669
fn trim_chars < ' a , C : CharEq > ( & ' a self , to_trim : C ) -> & ' a str ;
1650
1670
@@ -1657,10 +1677,14 @@ pub trait StrPrelude for Sized? {
1657
1677
/// # Example
1658
1678
///
1659
1679
/// ```rust
1680
+ /// # #![feature(unboxed_closures)]
1681
+ ///
1682
+ /// # fn main() {
1660
1683
/// assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11")
1661
1684
/// let x: &[_] = &['1', '2'];
1662
1685
/// assert_eq!("12foo1bar12".trim_left_chars(x), "foo1bar12")
1663
- /// assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_numeric()), "foo1bar123")
1686
+ /// assert_eq!("123foo1bar123".trim_left_chars(|&: c: char| c.is_numeric()), "foo1bar123")
1687
+ /// # }
1664
1688
/// ```
1665
1689
fn trim_left_chars < ' a , C : CharEq > ( & ' a self , to_trim : C ) -> & ' a str ;
1666
1690
@@ -1673,10 +1697,14 @@ pub trait StrPrelude for Sized? {
1673
1697
/// # Example
1674
1698
///
1675
1699
/// ```rust
1700
+ /// # #![feature(unboxed_closures)]
1701
+ ///
1702
+ /// # fn main() {
1676
1703
/// assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar")
1677
1704
/// let x: &[_] = &['1', '2'];
1678
1705
/// assert_eq!("12foo1bar12".trim_right_chars(x), "12foo1bar")
1679
- /// assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_numeric()), "123foo1bar")
1706
+ /// assert_eq!("123foo1bar123".trim_right_chars(|&: c: char| c.is_numeric()), "123foo1bar")
1707
+ /// # }
1680
1708
/// ```
1681
1709
fn trim_right_chars < ' a , C : CharEq > ( & ' a self , to_trim : C ) -> & ' a str ;
1682
1710
@@ -1817,17 +1845,21 @@ pub trait StrPrelude for Sized? {
1817
1845
/// # Example
1818
1846
///
1819
1847
/// ```rust
1848
+ /// # #![feature(unboxed_closures)]
1849
+ ///
1850
+ /// # fn main() {
1820
1851
/// let s = "Löwe 老虎 Léopard";
1821
1852
///
1822
1853
/// assert_eq!(s.find('L'), Some(0));
1823
1854
/// assert_eq!(s.find('é'), Some(14));
1824
1855
///
1825
1856
/// // the first space
1826
- /// assert_eq!(s.find(|c: char| c.is_whitespace()), Some(5));
1857
+ /// assert_eq!(s.find(|&: c: char| c.is_whitespace()), Some(5));
1827
1858
///
1828
1859
/// // neither are found
1829
1860
/// let x: &[_] = &['1', '2'];
1830
1861
/// assert_eq!(s.find(x), None);
1862
+ /// # }
1831
1863
/// ```
1832
1864
fn find < C : CharEq > ( & self , search : C ) -> Option < uint > ;
1833
1865
@@ -1842,17 +1874,21 @@ pub trait StrPrelude for Sized? {
1842
1874
/// # Example
1843
1875
///
1844
1876
/// ```rust
1877
+ /// # #![feature(unboxed_closures)]
1878
+ ///
1879
+ /// # fn main() {
1845
1880
/// let s = "Löwe 老虎 Léopard";
1846
1881
///
1847
1882
/// assert_eq!(s.rfind('L'), Some(13));
1848
1883
/// assert_eq!(s.rfind('é'), Some(14));
1849
1884
///
1850
1885
/// // the second space
1851
- /// assert_eq!(s.rfind(|c: char| c.is_whitespace()), Some(12));
1886
+ /// assert_eq!(s.rfind(|&: c: char| c.is_whitespace()), Some(12));
1852
1887
///
1853
1888
/// // searches for an occurrence of either `1` or `2`, but neither are found
1854
1889
/// let x: &[_] = &['1', '2'];
1855
1890
/// assert_eq!(s.rfind(x), None);
1891
+ /// # }
1856
1892
/// ```
1857
1893
fn rfind < C : CharEq > ( & self , search : C ) -> Option < uint > ;
1858
1894
0 commit comments