@@ -1511,6 +1511,13 @@ impl str {
15111511 /// 'Whitespace' is defined according to the terms of the Unicode Derived
15121512 /// Core Property `White_Space`.
15131513 ///
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+ ///
15141521 /// # Examples
15151522 ///
15161523 /// Basic usage:
@@ -1520,6 +1527,16 @@ impl str {
15201527 ///
15211528 /// assert_eq!("Hello\tworld\t", s.trim_left());
15221529 /// ```
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+ /// ```
15231540 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
15241541 pub fn trim_left ( & self ) -> & str {
15251542 UnicodeStr :: trim_left ( self )
@@ -1530,6 +1547,13 @@ impl str {
15301547 /// 'Whitespace' is defined according to the terms of the Unicode Derived
15311548 /// Core Property `White_Space`.
15321549 ///
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+ ///
15331557 /// # Examples
15341558 ///
15351559 /// Basic usage:
@@ -1539,6 +1563,16 @@ impl str {
15391563 ///
15401564 /// assert_eq!(" Hello\tworld", s.trim_right());
15411565 /// ```
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+ /// ```
15421576 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
15431577 pub fn trim_right ( & self ) -> & str {
15441578 UnicodeStr :: trim_right ( self )
@@ -1584,6 +1618,13 @@ impl str {
15841618 ///
15851619 /// [`char`]: primitive.char.html
15861620 ///
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+ ///
15871628 /// # Examples
15881629 ///
15891630 /// Basic usage:
@@ -1608,6 +1649,13 @@ impl str {
16081649 ///
16091650 /// [`char`]: primitive.char.html
16101651 ///
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+ ///
16111659 /// # Examples
16121660 ///
16131661 /// Simple patterns:
@@ -1644,7 +1692,7 @@ impl str {
16441692 ///
16451693 /// [`FromStr`]: str/trait.FromStr.html
16461694 ///
1647- /// # Failure
1695+ /// # Errors
16481696 ///
16491697 /// Will return `Err` if it's not possible to parse this string slice into
16501698 /// the desired type.
0 commit comments