diff --git a/src/doc/trpl/associated-types.md b/src/doc/trpl/associated-types.md index ec96880f12a95..fe4f27b9d954c 100644 --- a/src/doc/trpl/associated-types.md +++ b/src/doc/trpl/associated-types.md @@ -43,7 +43,7 @@ trait Graph { Now, our clients can be abstract over a given `Graph`: ```rust,ignore -fn distance(graph: &G, start: &G::N, end: &G::N) -> usize { ... } +fn distance(graph: &G, start: &G::N, end: &G::N) -> u32 { ... } ``` No need to deal with the `E`dge type here! diff --git a/src/doc/trpl/iterators.md b/src/doc/trpl/iterators.md index 249c1cc7e34f6..1c574f02091f8 100644 --- a/src/doc/trpl/iterators.md +++ b/src/doc/trpl/iterators.md @@ -285,8 +285,7 @@ has no side effect on the original iterator. Let's try it out with our infinite iterator from before: ```rust -# #![feature(step_by)] -for i in (1..).step_by(5).take(5) { +for i in (1..).take(5) { println!("{}", i); } ``` @@ -295,10 +294,10 @@ This will print ```text 1 -6 -11 -16 -21 +2 +3 +4 +5 ``` `filter()` is an adapter that takes a closure as an argument. This closure diff --git a/src/doc/trpl/lifetimes.md b/src/doc/trpl/lifetimes.md index 580960b7e8029..11d651c5778e3 100644 --- a/src/doc/trpl/lifetimes.md +++ b/src/doc/trpl/lifetimes.md @@ -305,7 +305,7 @@ fn substr<'a>(s: &'a str, until: u32) -> &'a str; // expanded fn get_str() -> &str; // ILLEGAL, no inputs fn frob(s: &str, t: &str) -> &str; // ILLEGAL, two inputs -fn frob<'a, 'b>(s: &'a str, t: &'b str) -> &str; // Expanded: Output lifetime is unclear +fn frob<'a, 'b>(s: &'a str, t: &'b str) -> &str; // Expanded: Output lifetime is ambiguous fn get_mut(&mut self) -> &mut T; // elided fn get_mut<'a>(&'a mut self) -> &'a mut T; // expanded diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index 946a833b3f864..a7ced76e10c18 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -187,22 +187,16 @@ impl char { /// # Examples /// /// ``` - /// for i in '❤'.escape_unicode() { - /// println!("{}", i); + /// for c in '❤'.escape_unicode() { + /// print!("{}", c); /// } + /// println!(""); /// ``` /// /// This prints: /// /// ```text - /// \ - /// u - /// { - /// 2 - /// 7 - /// 6 - /// 4 - /// } + /// \u{2764} /// ``` /// /// Collecting into a `String`: @@ -467,6 +461,12 @@ impl char { /// Returns an iterator which yields the characters corresponding to the /// lowercase equivalent of the character. If no conversion is possible then /// an iterator with just the input character is returned. + /// + /// # Examples + /// + /// ``` + /// assert_eq!(Some('c'), 'C'.to_lowercase().next()); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn to_lowercase(self) -> ToLowercase { @@ -515,6 +515,12 @@ impl char { /// [`SpecialCasing.txt`]: ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt /// /// [2]: http://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992 + /// + /// # Examples + /// + /// ``` + /// assert_eq!(Some('C'), 'c'.to_uppercase().next()); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn to_uppercase(self) -> ToUppercase {