diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2016-02-02 00:32:17 -0500 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2016-02-02 00:32:17 -0500 |
| commit | 7097d29411992b8752a20290c8daae1c5ea97118 (patch) | |
| tree | d9188480d5b3d9baf08d8816e14d86efbb3d379b /src/libcollections/str.rs | |
| parent | 78afc78d9d19c67dcf17e061b170230209dc3f19 (diff) | |
| parent | c0ace5dc16511a36fcfc0cf659959d4b0327d4f4 (diff) | |
| download | rust-7097d29411992b8752a20290c8daae1c5ea97118.tar.gz rust-7097d29411992b8752a20290c8daae1c5ea97118.zip | |
Rollup merge of #31202 - steveklabnik:gh30459, r=alexcrichton
Fixes #30459 Fun fact: i wanted to write "Arabic" and "Hebrew" in Arabic and Hebrew, but vim kept doing the copy/paste in the wrong direction.
Diffstat (limited to 'src/libcollections/str.rs')
| -rw-r--r-- | src/libcollections/str.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 094b7f1d034..4900b10eea2 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1511,6 +1511,13 @@ impl str { /// 'Whitespace' is defined according to the terms of the Unicode Derived /// Core Property `White_Space`. /// + /// # Text directionality + /// + /// A string is a sequence of bytes. 'Left' in this context means the first + /// position of that byte string; for a language like Arabic or Hebrew + /// which are 'right to left' rather than 'left to right', this will be + /// the _right_ side, not the left. + /// /// # Examples /// /// Basic usage: @@ -1520,6 +1527,16 @@ impl str { /// /// assert_eq!("Hello\tworld\t", s.trim_left()); /// ``` + /// + /// Directionality: + /// + /// ``` + /// let s = " English"; + /// assert!(Some('E') == s.trim_left().chars().next()); + /// + /// let s = " עברית"; + /// assert!(Some('ע') == s.trim_left().chars().next()); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn trim_left(&self) -> &str { UnicodeStr::trim_left(self) @@ -1530,6 +1547,13 @@ impl str { /// 'Whitespace' is defined according to the terms of the Unicode Derived /// Core Property `White_Space`. /// + /// # Text directionality + /// + /// A string is a sequence of bytes. 'Right' in this context means the last + /// position of that byte string; for a language like Arabic or Hebrew + /// which are 'right to left' rather than 'left to right', this will be + /// the _left_ side, not the right. + /// /// # Examples /// /// Basic usage: @@ -1539,6 +1563,16 @@ impl str { /// /// assert_eq!(" Hello\tworld", s.trim_right()); /// ``` + /// + /// Directionality: + /// + /// ``` + /// let s = "English "; + /// assert!(Some('h') == s.trim_right().chars().rev().next()); + /// + /// let s = "עברית "; + /// assert!(Some('ת') == s.trim_right().chars().rev().next()); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn trim_right(&self) -> &str { UnicodeStr::trim_right(self) @@ -1584,6 +1618,13 @@ impl str { /// /// [`char`]: primitive.char.html /// + /// # Text directionality + /// + /// A string is a sequence of bytes. 'Left' in this context means the first + /// position of that byte string; for a language like Arabic or Hebrew + /// which are 'right to left' rather than 'left to right', this will be + /// the _right_ side, not the left. + /// /// # Examples /// /// Basic usage: @@ -1608,6 +1649,13 @@ impl str { /// /// [`char`]: primitive.char.html /// + /// # Text directionality + /// + /// A string is a sequence of bytes. 'Right' in this context means the last + /// position of that byte string; for a language like Arabic or Hebrew + /// which are 'right to left' rather than 'left to right', this will be + /// the _left_ side, not the right. + /// /// # Examples /// /// Simple patterns: |
