Skip to content

Commit

Permalink
Make features stable and clarify examples
Browse files Browse the repository at this point in the history
  • Loading branch information
varkor committed Aug 5, 2018
1 parent 33067ad commit 3e10ffc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#![feature(unboxed_closures)]
#![feature(exact_chunks)]
#![feature(repeat_generic_slice)]
#![feature(trim_direction)]

extern crate alloc_system;
extern crate core;
Expand Down
30 changes: 8 additions & 22 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3604,24 +3604,20 @@ impl str {
/// Basic usage:
///
/// ```
/// #![feature(trim_direction)]
///
/// let s = " Hello\tworld\t";
/// assert_eq!("Hello\tworld\t", s.trim_start());
/// ```
///
/// Directionality:
///
/// ```
/// #![feature(trim_direction)]
///
/// let s = " English";
/// let s = " English ";
/// assert!(Some('E') == s.trim_start().chars().next());
///
/// let s = " עברית";
/// let s = " עברית ";
/// assert!(Some('ע') == s.trim_start().chars().next());
/// ```
#[unstable(feature = "trim_direction", issue = "30459")]
#[stable(feature = "trim_direction", since = "1.30.0")]
pub fn trim_start(&self) -> &str {
self.trim_start_matches(|c: char| c.is_whitespace())
}
Expand All @@ -3643,24 +3639,20 @@ impl str {
/// Basic usage:
///
/// ```
/// #![feature(trim_direction)]
///
/// let s = " Hello\tworld\t";
/// assert_eq!(" Hello\tworld", s.trim_end());
/// ```
///
/// Directionality:
///
/// ```
/// #![feature(trim_direction)]
///
/// let s = "English ";
/// let s = " English ";
/// assert!(Some('h') == s.trim_end().chars().rev().next());
///
/// let s = "עברית ";
/// let s = " עברית ";
/// assert!(Some('ת') == s.trim_end().chars().rev().next());
/// ```
#[unstable(feature = "trim_direction", issue = "30459")]
#[stable(feature = "trim_direction", since = "1.30.0")]
pub fn trim_end(&self) -> &str {
self.trim_end_matches(|c: char| c.is_whitespace())
}
Expand Down Expand Up @@ -3805,15 +3797,13 @@ impl str {
/// Basic usage:
///
/// ```
/// #![feature(trim_direction)]
///
/// assert_eq!("11foo1bar11".trim_start_matches('1'), "foo1bar11");
/// assert_eq!("123foo1bar123".trim_start_matches(char::is_numeric), "foo1bar123");
///
/// let x: &[_] = &['1', '2'];
/// assert_eq!("12foo1bar12".trim_start_matches(x), "foo1bar12");
/// ```
#[unstable(feature = "trim_direction", issue = "30459")]
#[stable(feature = "trim_direction", since = "1.30.0")]
pub fn trim_start_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str {
let mut i = self.len();
let mut matcher = pat.into_searcher(self);
Expand Down Expand Up @@ -3846,8 +3836,6 @@ impl str {
/// Simple patterns:
///
/// ```
/// #![feature(trim_direction)]
///
/// assert_eq!("11foo1bar11".trim_end_matches('1'), "11foo1bar");
/// assert_eq!("123foo1bar123".trim_end_matches(char::is_numeric), "123foo1bar");
///
Expand All @@ -3858,11 +3846,9 @@ impl str {
/// A more complex pattern, using a closure:
///
/// ```
/// #![feature(trim_direction)]
///
/// assert_eq!("1fooX".trim_end_matches(|c| c == '1' || c == 'X'), "1foo");
/// ```
#[unstable(feature = "trim_direction", issue = "30459")]
#[stable(feature = "trim_direction", since = "1.30.0")]
pub fn trim_end_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
where P::Searcher: ReverseSearcher<'a>
{
Expand Down

0 comments on commit 3e10ffc

Please sign in to comment.