From 1254c34032673d5f9d7775d894bc58e7ad68ba01 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 18 May 2015 16:58:29 -0400 Subject: Add example for from_str_radix Fixes #25517 --- src/libcore/num/mod.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 011830ddb78..75040b4c425 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -132,15 +132,11 @@ macro_rules! int_impl { /// /// Leading and trailing whitespace represent an error. /// - /// # Arguments - /// - /// * src - A string slice - /// * radix - The base to use. Must lie in the range [2 .. 36] - /// - /// # Return value + /// # Examples /// - /// `Err(ParseIntError)` if the string did not represent a valid number. - /// Otherwise, `Ok(n)` where `n` is the integer represented by `src`. + /// ``` + /// assert_eq!(u32::from_str_radix("A", 16), Some(10)); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub fn from_str_radix(src: &str, radix: u32) -> Result<$T, ParseIntError> { -- cgit 1.4.1-3-g733a5 From 733e7eea5c459c67173e369c1deac3bcde8f03ef Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Tue, 19 May 2015 19:21:52 +0700 Subject: fmt.rs: add note about lack of padding support for some types --- src/libcollections/fmt.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index 80fa6d397c8..cb023bcb7a5 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -353,6 +353,10 @@ //! * `^` - the argument is center-aligned in `width` columns //! * `>` - the argument is right-aligned in `width` columns //! +//! Note that alignment may not be implemented by some types. A good way +//! to ensure padding is applied is to format your input, then use this +//! resulting string to pad your output. +//! //! ## Sign/#/0 //! //! These can all be interpreted as flags for a particular formatter. -- cgit 1.4.1-3-g733a5 From aa570bce3e35f1fba5a5fe488e40c31ceff1207c Mon Sep 17 00:00:00 2001 From: Mohammed Attia Date: Tue, 19 May 2015 14:38:54 +0200 Subject: Fix lifetimes trpl typo --- src/doc/trpl/lifetimes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/lifetimes.md b/src/doc/trpl/lifetimes.md index 342de413f0b..0039f90b82c 100644 --- a/src/doc/trpl/lifetimes.md +++ b/src/doc/trpl/lifetimes.md @@ -219,7 +219,7 @@ to it. ## Lifetime Elision Rust supports powerful local type inference in function bodies, but it’s -forbidden in item signatures to allow reasoning about the types just based in +forbidden in item signatures to allow reasoning about the types based on the item signature alone. However, for ergonomic reasons a very restricted secondary inference algorithm called “lifetime elision” applies in function signatures. It infers only based on the signature components themselves and not -- cgit 1.4.1-3-g733a5 From afbe15d103dd12e177b7fa875b8c21d43e2f15a3 Mon Sep 17 00:00:00 2001 From: peferron Date: Mon, 18 May 2015 13:39:19 -0700 Subject: Fix description of assert! --- src/doc/trpl/macros.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/trpl/macros.md b/src/doc/trpl/macros.md index d504fab206d..5660f7c198f 100644 --- a/src/doc/trpl/macros.md +++ b/src/doc/trpl/macros.md @@ -683,9 +683,9 @@ let v = vec![0; 100]; ## assert! and assert_eq! -These two macros are used in tests. `assert!` takes a boolean, and `assert_eq!` -takes two values and compares them. Truth passes, success `panic!`s. Like -this: +These two macros are used in tests. `assert!` takes a boolean. `assert_eq!` +takes two values and checks them for equality. `true` passes, `false` `panic!`s. +Like this: ```rust,no_run // A-ok! -- cgit 1.4.1-3-g733a5 From c9c474cb862a02eb15c15882fe331c6f9bdb7524 Mon Sep 17 00:00:00 2001 From: parir Date: Tue, 19 May 2015 19:19:42 +0200 Subject: doc: add missing fences --- src/libcollections/str.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 198627ad2fc..a3ffdedb8c1 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1841,8 +1841,10 @@ impl str { /// /// # Examples /// + /// ``` /// let s = "HELLO"; /// assert_eq!(s.to_lowercase(), "hello"); + /// ``` #[unstable(feature = "collections")] pub fn to_lowercase(&self) -> String { let mut s = String::with_capacity(self.len()); @@ -1854,8 +1856,10 @@ impl str { /// /// # Examples /// + /// ``` /// let s = "hello"; /// assert_eq!(s.to_uppercase(), "HELLO"); + /// ``` #[unstable(feature = "collections")] pub fn to_uppercase(&self) -> String { let mut s = String::with_capacity(self.len()); -- cgit 1.4.1-3-g733a5 From 3b95cd71fe9e84a37f98c655ac8bf39e44bdb0b3 Mon Sep 17 00:00:00 2001 From: parir Date: Tue, 19 May 2015 19:36:10 +0200 Subject: doc: fix a broken link --- src/librustc_unicode/char.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index 31186192209..9dfd172707d 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -429,7 +429,7 @@ impl char { /// /// [1]: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt /// - /// [`SpecialCasing`.txt`]: ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt + /// [`SpecialCasing.txt`]: ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt /// /// [2]: http://www.unicode.org/versions/Unicode4.0.0/ch03.pdf#G33992 #[stable(feature = "rust1", since = "1.0.0")] -- cgit 1.4.1-3-g733a5 From 01c93a59e8bc7588d43e75125cdca769b0b3571c Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 19 May 2015 11:34:34 -0700 Subject: mk: Report the prerelease version on beta again. Fixes #25618 --- mk/main.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/main.mk b/mk/main.mk index b3c02841340..291920cf7a8 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -32,7 +32,7 @@ CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM) CFG_DISABLE_UNSTABLE_FEATURES=1 endif ifeq ($(CFG_RELEASE_CHANNEL),beta) -CFG_RELEASE=$(CFG_RELEASE_NUM)-beta +CFG_RELEASE=$(CFG_RELEASE_NUM)-beta$(CFG_PRERELEASE_VERSION) # When building beta distributables just reuse the same "beta" name # so when we upload we'll always override the previous beta. This # doesn't actually impact the version reported by rustc - it's just -- cgit 1.4.1-3-g733a5 From b748c2e90d87985fbff1d99e17d94a10cf2b3f21 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Mon, 18 May 2015 23:48:09 +0200 Subject: Change default gender in the dining philosophers project The paper from which this example was taken made the mistake of assuming that all five philosophers are men. This is a hypothetical example--there are no actual philosophers eating spaghetti--so there is no good reason to make this assumption. Since women make up about half of the human population, all things being equal, women should represent about half of the philosophers. However, because this mistake has stood since 1985, I have changed *all* of the pronouns to be female, to make up for lost time. If someone would like to revert this patch or switch to neutral pronouns after 30 years, feel free to set your alarm clock for 2045. --- src/doc/trpl/dining-philosophers.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/doc/trpl/dining-philosophers.md b/src/doc/trpl/dining-philosophers.md index cb02072566e..4c230c3b0e6 100644 --- a/src/doc/trpl/dining-philosophers.md +++ b/src/doc/trpl/dining-philosophers.md @@ -7,20 +7,20 @@ called ‘the dining philosophers’. It was originally conceived by Dijkstra in [paper]: http://www.usingcsp.com/cspbook.pdf > In ancient times, a wealthy philanthropist endowed a College to accommodate -> five eminent philosophers. Each philosopher had a room in which he could -> engage in his professional activity of thinking; there was also a common +> five eminent philosophers. Each philosopher had a room in which she could +> engage in her professional activity of thinking; there was also a common > dining room, furnished with a circular table, surrounded by five chairs, each > labelled by the name of the philosopher who was to sit in it. They sat > anticlockwise around the table. To the left of each philosopher there was > laid a golden fork, and in the centre stood a large bowl of spaghetti, which -> was constantly replenished. A philosopher was expected to spend most of his -> time thinking; but when he felt hungry, he went to the dining room, sat down -> in his own chair, picked up his own fork on his left, and plunged it into the +> was constantly replenished. A philosopher was expected to spend most of her +> time thinking; but when she felt hungry, she went to the dining room, sat down +> in her own chair, picked up her own fork on her left, and plunged it into the > spaghetti. But such is the tangled nature of spaghetti that a second fork is > required to carry it to the mouth. The philosopher therefore had also to pick -> up the fork on his right. When he was finished he would put down both his -> forks, get up from his chair, and continue thinking. Of course, a fork can be -> used by only one philosopher at a time. If the other philosopher wants it, he +> up the fork on her right. When she was finished she would put down both her +> forks, get up from her chair, and continue thinking. Of course, a fork can be +> used by only one philosopher at a time. If the other philosopher wants it, she > just has to wait until the fork is available again. This classic problem shows off a few different elements of concurrency. The -- cgit 1.4.1-3-g733a5 From 55da4c69752119b80f17351784de45f66540066f Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 19 May 2015 21:26:21 -0400 Subject: Small fix for https://github.com/rust-lang/rust/pull/25611 --- src/libcollections/str.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index a3ffdedb8c1..b390055664b 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1842,6 +1842,8 @@ impl str { /// # Examples /// /// ``` + /// #![feature(collections)] + /// /// let s = "HELLO"; /// assert_eq!(s.to_lowercase(), "hello"); /// ``` @@ -1857,6 +1859,8 @@ impl str { /// # Examples /// /// ``` + /// #![feature(collections)] + /// /// let s = "hello"; /// assert_eq!(s.to_uppercase(), "HELLO"); /// ``` -- cgit 1.4.1-3-g733a5 From 395d01cf64579312b9b6924d8056264abaaf33f7 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 19 May 2015 23:22:28 -0400 Subject: Fix for https://github.com/rust-lang/rust/pull/25583 --- src/libcore/num/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 91faba7376b..e560fae31a1 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -135,7 +135,7 @@ macro_rules! int_impl { /// # Examples /// /// ``` - /// assert_eq!(u32::from_str_radix("A", 16), Some(10)); + /// assert_eq!(u32::from_str_radix("A", 16), Ok(10)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] -- cgit 1.4.1-3-g733a5