Skip to content

Commit 743bad4

Browse files
committed
Add doctests for directionality
Thanks @nodakai
1 parent 5a5aaca commit 743bad4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/libcollections/str.rs

+20
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,16 @@ impl str {
15311531
///
15321532
/// assert_eq!("Hello\tworld\t", s.trim_left());
15331533
/// ```
1534+
///
1535+
/// Directionality:
1536+
///
1537+
/// ```
1538+
/// let s = " English";
1539+
/// assert!(Some('E') == s.trim_left().chars().next());
1540+
///
1541+
/// let s = " עברית";
1542+
/// assert!(Some('ע') == s.trim_left().chars().next());
1543+
/// ```
15341544
#[stable(feature = "rust1", since = "1.0.0")]
15351545
pub fn trim_left(&self) -> &str {
15361546
UnicodeStr::trim_left(self)
@@ -1557,6 +1567,16 @@ impl str {
15571567
///
15581568
/// assert_eq!(" Hello\tworld", s.trim_right());
15591569
/// ```
1570+
///
1571+
/// Directionality:
1572+
///
1573+
/// ```
1574+
/// let s = "English ";
1575+
/// assert!(Some('E') == s.trim_right().chars().next());
1576+
///
1577+
/// let s = "עברית ";
1578+
/// assert!(Some('ת') == s.trim_right().chars().next());
1579+
/// ```
15601580
#[stable(feature = "rust1", since = "1.0.0")]
15611581
pub fn trim_right(&self) -> &str {
15621582
UnicodeStr::trim_right(self)

0 commit comments

Comments
 (0)