From cec158b6b7c488c93f16bbe07b6082d5e4f2f7b1 Mon Sep 17 00:00:00 2001 From: "NODA, Kai" Date: Thu, 11 Feb 2016 00:55:47 +0800 Subject: doc: concat_idents! macro: more on its limitations. Signed-off-by: NODA, Kai --- src/libstd/macros.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index b7afd12d8e5..d241cd032ed 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -269,9 +269,10 @@ pub mod builtin { /// This macro takes any number of comma-separated identifiers, and /// concatenates them all into one, yielding an expression which is a new /// identifier. Note that hygiene makes it such that this macro cannot - /// capture local variables, and macros are only allowed in item, - /// statement or expression position, meaning this macro may be difficult to - /// use in some situations. + /// capture local variables. Also, as a general rule, macros are only + /// allowed in item, statement or expression position. That means while + /// you may use this macro for referring to existing variables, functions or + /// modules etc, you cannot define a new one with it. /// /// # Examples /// @@ -283,6 +284,8 @@ pub mod builtin { /// /// let f = concat_idents!(foo, bar); /// println!("{}", f()); + /// + /// // fn concat_idents!(new, fun, name) { } // not usable in this way! /// # } /// ``` #[stable(feature = "rust1", since = "1.0.0")] -- cgit 1.4.1-3-g733a5 From c64088588a3f456b056b559a017850af39c5ff0a Mon Sep 17 00:00:00 2001 From: Scott Whittaker Date: Wed, 10 Feb 2016 22:28:32 -0500 Subject: mod.rs: fix typo "destructors" was misspelled. --- src/libstd/prelude/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/prelude/mod.rs b/src/libstd/prelude/mod.rs index a0db471dece..ebd299efa78 100644 --- a/src/libstd/prelude/mod.rs +++ b/src/libstd/prelude/mod.rs @@ -55,7 +55,7 @@ //! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`]}. The marker //! traits indicate fundamental properties of types. //! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}. Various -//! operations for both destuctors and overloading `()`. +//! operations for both destructors and overloading `()`. //! * [`std::mem`]::[`drop`], a convenience function for explicitly dropping a //! value. //! * [`std::boxed`]::[`Box`], a way to allocate values on the heap. -- cgit 1.4.1-3-g733a5 From 583f638a733965deb66c0c4db73718a1183a6189 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 11 Feb 2016 22:59:34 +0200 Subject: doc: add missing words --- src/libstd/ascii.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 38f79079b29..b5c01077a7b 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -45,7 +45,7 @@ pub trait AsciiExt { #[stable(feature = "rust1", since = "1.0.0")] type Owned; - /// Checks if within the ASCII range. + /// Checks if the value is within the ASCII range. /// /// # Examples /// -- cgit 1.4.1-3-g733a5 From 2f20d5aa5f3392a38643f17683dd25c1dd7062c2 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Thu, 11 Feb 2016 23:05:00 +0200 Subject: doc: assert_eq on 2 boolean values is redundant --- src/libstd/ascii.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 38f79079b29..83cf670502f 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -55,8 +55,8 @@ pub trait AsciiExt { /// let ascii = 'a'; /// let utf8 = '❤'; /// - /// assert_eq!(true, ascii.is_ascii()); - /// assert_eq!(false, utf8.is_ascii()) + /// assert!(ascii.is_ascii()); + /// assert!(!utf8.is_ascii()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn is_ascii(&self) -> bool; @@ -114,9 +114,9 @@ pub trait AsciiExt { /// let ascii3 = 'A'; /// let ascii4 = 'z'; /// - /// assert_eq!(true, ascii1.eq_ignore_ascii_case(&ascii2)); - /// assert_eq!(true, ascii1.eq_ignore_ascii_case(&ascii3)); - /// assert_eq!(false, ascii1.eq_ignore_ascii_case(&ascii4)); + /// assert!(ascii1.eq_ignore_ascii_case(&ascii2)); + /// assert!(ascii1.eq_ignore_ascii_case(&ascii3)); + /// assert!(!ascii1.eq_ignore_ascii_case(&ascii4)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] fn eq_ignore_ascii_case(&self, other: &Self) -> bool; -- cgit 1.4.1-3-g733a5 From 8bbb70cb94bfbe485e94994b2da35675597586c6 Mon Sep 17 00:00:00 2001 From: Jonathan Reem Date: Thu, 11 Feb 2016 17:24:57 -0800 Subject: Remove unnecessary bounds on Error and Display implementations for TryLockError and PoisonError. --- src/libstd/sys/common/poison.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/common/poison.rs b/src/libstd/sys/common/poison.rs index 2cfa04c843b..d858c002755 100644 --- a/src/libstd/sys/common/poison.rs +++ b/src/libstd/sys/common/poison.rs @@ -111,7 +111,7 @@ impl fmt::Display for PoisonError { } #[stable(feature = "rust1", since = "1.0.0")] -impl Error for PoisonError { +impl Error for PoisonError { fn description(&self) -> &str { "poisoned lock: another task failed inside" } @@ -158,14 +158,17 @@ impl fmt::Debug for TryLockError { } #[stable(feature = "rust1", since = "1.0.0")] -impl fmt::Display for TryLockError { +impl fmt::Display for TryLockError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.description().fmt(f) + match *self { + TryLockError::Poisoned(..) => "poisoned lock: another task failed inside", + TryLockError::WouldBlock => "try_lock failed because the operation would block" + }.fmt(f) } } #[stable(feature = "rust1", since = "1.0.0")] -impl Error for TryLockError { +impl Error for TryLockError { fn description(&self) -> &str { match *self { TryLockError::Poisoned(ref p) => p.description(), -- cgit 1.4.1-3-g733a5