@@ -1511,6 +1511,13 @@ impl str {
1511
1511
/// 'Whitespace' is defined according to the terms of the Unicode Derived
1512
1512
/// Core Property `White_Space`.
1513
1513
///
1514
+ /// # Text directionality
1515
+ ///
1516
+ /// A string is a sequence of bytes. 'Left' in this context means the first
1517
+ /// position of that byte string; for a language like Arabic or Hebrew
1518
+ /// which are 'right to left' rather than 'left to right', this will be
1519
+ /// the _right_ side, not the left.
1520
+ ///
1514
1521
/// # Examples
1515
1522
///
1516
1523
/// Basic usage:
@@ -1520,6 +1527,16 @@ impl str {
1520
1527
///
1521
1528
/// assert_eq!("Hello\tworld\t", s.trim_left());
1522
1529
/// ```
1530
+ ///
1531
+ /// Directionality:
1532
+ ///
1533
+ /// ```
1534
+ /// let s = " English";
1535
+ /// assert!(Some('E') == s.trim_left().chars().next());
1536
+ ///
1537
+ /// let s = " עברית";
1538
+ /// assert!(Some('ע') == s.trim_left().chars().next());
1539
+ /// ```
1523
1540
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1524
1541
pub fn trim_left ( & self ) -> & str {
1525
1542
UnicodeStr :: trim_left ( self )
@@ -1530,6 +1547,13 @@ impl str {
1530
1547
/// 'Whitespace' is defined according to the terms of the Unicode Derived
1531
1548
/// Core Property `White_Space`.
1532
1549
///
1550
+ /// # Text directionality
1551
+ ///
1552
+ /// A string is a sequence of bytes. 'Right' in this context means the last
1553
+ /// position of that byte string; for a language like Arabic or Hebrew
1554
+ /// which are 'right to left' rather than 'left to right', this will be
1555
+ /// the _left_ side, not the right.
1556
+ ///
1533
1557
/// # Examples
1534
1558
///
1535
1559
/// Basic usage:
@@ -1539,6 +1563,16 @@ impl str {
1539
1563
///
1540
1564
/// assert_eq!(" Hello\tworld", s.trim_right());
1541
1565
/// ```
1566
+ ///
1567
+ /// Directionality:
1568
+ ///
1569
+ /// ```
1570
+ /// let s = "English ";
1571
+ /// assert!(Some('h') == s.trim_right().chars().rev().next());
1572
+ ///
1573
+ /// let s = "עברית ";
1574
+ /// assert!(Some('ת') == s.trim_right().chars().rev().next());
1575
+ /// ```
1542
1576
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1543
1577
pub fn trim_right ( & self ) -> & str {
1544
1578
UnicodeStr :: trim_right ( self )
@@ -1584,6 +1618,13 @@ impl str {
1584
1618
///
1585
1619
/// [`char`]: primitive.char.html
1586
1620
///
1621
+ /// # Text directionality
1622
+ ///
1623
+ /// A string is a sequence of bytes. 'Left' in this context means the first
1624
+ /// position of that byte string; for a language like Arabic or Hebrew
1625
+ /// which are 'right to left' rather than 'left to right', this will be
1626
+ /// the _right_ side, not the left.
1627
+ ///
1587
1628
/// # Examples
1588
1629
///
1589
1630
/// Basic usage:
@@ -1608,6 +1649,13 @@ impl str {
1608
1649
///
1609
1650
/// [`char`]: primitive.char.html
1610
1651
///
1652
+ /// # Text directionality
1653
+ ///
1654
+ /// A string is a sequence of bytes. 'Right' in this context means the last
1655
+ /// position of that byte string; for a language like Arabic or Hebrew
1656
+ /// which are 'right to left' rather than 'left to right', this will be
1657
+ /// the _left_ side, not the right.
1658
+ ///
1611
1659
/// # Examples
1612
1660
///
1613
1661
/// Simple patterns:
@@ -1644,7 +1692,7 @@ impl str {
1644
1692
///
1645
1693
/// [`FromStr`]: str/trait.FromStr.html
1646
1694
///
1647
- /// # Failure
1695
+ /// # Errors
1648
1696
///
1649
1697
/// Will return `Err` if it's not possible to parse this string slice into
1650
1698
/// the desired type.
0 commit comments