From c8292fcd6ad2a06d2529f5dcea4b9133930211b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20CORTIER?= Date: Wed, 15 Feb 2017 13:44:52 +0100 Subject: [PATCH 1/6] Correct a typo in procedural macros chapter of the Book. --- src/doc/book/src/procedural-macros.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/src/procedural-macros.md b/src/doc/book/src/procedural-macros.md index d286c3b7bdc63..334f5e8d6567b 100644 --- a/src/doc/book/src/procedural-macros.md +++ b/src/doc/book/src/procedural-macros.md @@ -169,7 +169,7 @@ So this is where quotes comes in. The `ast` argument is a struct that gives us a representation of our type (which can be either a `struct` or an `enum`). Check out the [docs](https://docs.rs/syn/0.10.5/syn/struct.MacroInput.html), there is some useful information there. We are able to get the name of the -type using `ast.ident`. The `quote!` macro let's us write up the Rust code +type using `ast.ident`. The `quote!` macro let us write up the Rust code that we wish to return and convert it into `Tokens`. `quote!` let's us use some really cool templating mechanics; we simply write `#name` and `quote!` will replace it with the variable named `name`. You can even do some repetition From 1fbbe79bcb97cc85dfe5f6c431b7aca9784a9bd4 Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Wed, 15 Feb 2017 23:26:29 +0100 Subject: [PATCH 2/6] Fix wording in LocalKey documentation --- src/libstd/sync/once.rs | 2 +- src/libstd/thread/local.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index ba99375139139..1e7394c0b09e7 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -316,7 +316,7 @@ impl Once { } // Once we've enqueued ourselves, wait in a loop. - // Aftewards reload the state and continue with what we + // Afterwards reload the state and continue with what we // were doing from before. while !node.signaled.load(Ordering::SeqCst) { thread::park(); diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 5166ddf8a21b6..66f09a7069c13 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -28,8 +28,8 @@ use mem; /// # Initialization and Destruction /// /// Initialization is dynamically performed on the first call to `with()` -/// within a thread, and values support destructors which will be run when a -/// thread exits. +/// within a thread, and values that implement `Drop` get destructed when a +/// thread exits. Some caveats apply, which are explained below. /// /// # Examples /// From 36b00cf217f354b9169cc5c529642bfd958295a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20CORTIER?= Date: Thu, 16 Feb 2017 09:18:19 +0100 Subject: [PATCH 3/6] Correct a typo in procedural macros chapter of the Book. (fixup [c8292fcd6ad2a06d2529f5]) --- src/doc/book/src/procedural-macros.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/src/procedural-macros.md b/src/doc/book/src/procedural-macros.md index 334f5e8d6567b..df49c70aada73 100644 --- a/src/doc/book/src/procedural-macros.md +++ b/src/doc/book/src/procedural-macros.md @@ -169,7 +169,7 @@ So this is where quotes comes in. The `ast` argument is a struct that gives us a representation of our type (which can be either a `struct` or an `enum`). Check out the [docs](https://docs.rs/syn/0.10.5/syn/struct.MacroInput.html), there is some useful information there. We are able to get the name of the -type using `ast.ident`. The `quote!` macro let us write up the Rust code +type using `ast.ident`. The `quote!` macro lets us write up the Rust code that we wish to return and convert it into `Tokens`. `quote!` let's us use some really cool templating mechanics; we simply write `#name` and `quote!` will replace it with the variable named `name`. You can even do some repetition From 860900cfc348e0579eac3acb07097161306d7908 Mon Sep 17 00:00:00 2001 From: king6cong Date: Fri, 17 Feb 2017 09:47:37 +0800 Subject: [PATCH 4/6] code order tweak --- src/libcore/iter/iterator.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index d41767cce18fe..3785bbe9bb0e4 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -1603,12 +1603,12 @@ pub trait Iterator { let mut i = self.len(); while let Some(v) = self.next_back() { - if predicate(v) { - return Some(i - 1); - } // No need for an overflow check here, because `ExactSizeIterator` // implies that the number of elements fits into a `usize`. i -= 1; + if predicate(v) { + return Some(i); + } } None } From eec9e988e18ff33a60dc7a9056bf2d4a35fd2a20 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 16 Feb 2017 22:49:46 -0800 Subject: [PATCH 5/6] Fixup String::split_off documentation 1. Clarify that `String::split_off` returns one string and modifies self in-place. The documentation implied that it returns two new strings. 2. Make the documentation mirror `Vec::split_off`. --- src/libcollections/string.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 4c82e2e2e7e35..e92eb4ff7bdd4 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1250,17 +1250,17 @@ impl String { self.len() == 0 } - /// Divide one string into two at an index. + /// Splits the string into two at the given index. /// - /// The argument, `mid`, should be a byte offset from the start of the string. It must also - /// be on the boundary of a UTF-8 code point. + /// Returns a newly allocated `String`. `self` contains bytes `[0, at)`, and + /// the returned `String` contains bytes `[at, len)`. `at` must be on the + /// boundary of a UTF-8 code point. /// - /// The two strings returned go from the start of the string to `mid`, and from `mid` to the end - /// of the string. + /// Note that the capacity of `self` does not change. /// /// # Panics /// - /// Panics if `mid` is not on a `UTF-8` code point boundary, or if it is beyond the last + /// Panics if `at` is not on a `UTF-8` code point boundary, or if it is beyond the last /// code point of the string. /// /// # Examples @@ -1275,9 +1275,9 @@ impl String { /// ``` #[inline] #[stable(feature = "string_split_off", since = "1.16.0")] - pub fn split_off(&mut self, mid: usize) -> String { - assert!(self.is_char_boundary(mid)); - let other = self.vec.split_off(mid); + pub fn split_off(&mut self, at: usize) -> String { + assert!(self.is_char_boundary(at)); + let other = self.vec.split_off(at); unsafe { String::from_utf8_unchecked(other) } } From 84aca88cdab3df70d1dc657cc203d38672a7e95c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 18 Feb 2017 14:44:56 +0100 Subject: [PATCH 6/6] Add missing urls for env functions --- src/libstd/env.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 1ef2cb4ed153c..dd4f1ff4f5ed7 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -96,7 +96,9 @@ pub struct VarsOs { inner: os_imp::Env } /// /// While iterating, the returned iterator will panic if any key or value in the /// environment is not valid unicode. If this is not desired, consider using the -/// `env::vars_os` function. +/// [`env::vars_os`] function. +/// +/// [`env::vars_os`]: fn.vars_os.html /// /// # Examples /// @@ -171,9 +173,12 @@ impl fmt::Debug for VarsOs { /// Fetches the environment variable `key` from the current process. /// -/// The returned result is `Ok(s)` if the environment variable is present and is +/// The returned result is [`Ok(s)`] if the environment variable is present and is /// valid unicode. If the environment variable is not present, or it is not -/// valid unicode, then `Err` will be returned. +/// valid unicode, then [`Err`] will be returned. +/// +/// [`Ok(s)`]: ../result/enum.Result.html#variant.Ok +/// [`Err`]: ../result/enum.Result.html#variant.Err /// /// # Examples /// @@ -199,7 +204,9 @@ fn _var(key: &OsStr) -> Result { } /// Fetches the environment variable `key` from the current process, returning -/// `None` if the variable isn't set. +/// [`None`] if the variable isn't set. +/// +/// [`None`]: ../option/enum.Option.html#variant.None /// /// # Examples ///