From 5a5aacac1f6f06fdbff415e74e9f71ebf6443a4d Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 25 Jan 2016 22:57:57 -0500 Subject: [PATCH 1/2] Document LTR vs RTL wrt trim_* The doc part of #30459 --- src/libcollections/str.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 9ce1a111cf83a..03474a45fead7 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1515,6 +1515,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: @@ -1534,6 +1541,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: @@ -1588,6 +1602,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: @@ -1612,6 +1633,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: From c0ace5dc16511a36fcfc0cf659959d4b0327d4f4 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 1 Feb 2016 11:26:23 -0500 Subject: [PATCH 2/2] Add doctests for directionality Thanks @nodakai --- src/libcollections/str.rs | 20 ++++++++++++++++++++ src/liblibc | 2 +- src/llvm | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 03474a45fead7..dcba0be4b17b0 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1531,6 +1531,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) @@ -1557,6 +1567,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) diff --git a/src/liblibc b/src/liblibc index af77843345ec6..30f70baa6cc1b 160000 --- a/src/liblibc +++ b/src/liblibc @@ -1 +1 @@ -Subproject commit af77843345ec6fc7e51113bfd692138d89024bc0 +Subproject commit 30f70baa6cc1ba3ddebb55b988fafbad0c0cc810 diff --git a/src/llvm b/src/llvm index 3564439515985..de5c31045dc0f 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 3564439515985dc1cc0d77057ed00901635a80ad +Subproject commit de5c31045dc0f6da1f65d02ee640ccf99ba90e7c