From 5fa50d995b2a07561268f9a371fb089170f16a11 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Sat, 18 Feb 2017 09:57:33 +0000 Subject: [PATCH 1/4] Variable Bindings possible nitpick Complete drive by nitpick I'm afraid --- src/doc/book/src/variable-bindings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/src/variable-bindings.md b/src/doc/book/src/variable-bindings.md index 0c8324d83e073..d6aa8b1acb72f 100644 --- a/src/doc/book/src/variable-bindings.md +++ b/src/doc/book/src/variable-bindings.md @@ -181,7 +181,7 @@ print. # Scope and shadowing Let’s get back to bindings. Variable bindings have a scope - they are -constrained to live in a block they were defined in. A block is a collection +constrained to live in the block they were defined in. A block is a collection of statements enclosed by `{` and `}`. Function definitions are also blocks! In the following example we define two variable bindings, `x` and `y`, which live in different blocks. `x` can be accessed from inside the `fn main() {}` From 3b4412aa62e25c7e4952211a7844012a67792b27 Mon Sep 17 00:00:00 2001 From: arthurprs Date: Sat, 18 Feb 2017 21:06:00 +0100 Subject: [PATCH 2/4] Fix spelling in comments --- src/libstd/collections/hash/map.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 079dbd667d65b..fd5827b4c0753 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -182,15 +182,15 @@ impl DefaultResizePolicy { // ---------------------- // To protect against degenerate performance scenarios (including DOS attacks), // the implementation includes an adaptive behavior that can resize the map -// early (before it's capacity is exceeded) when suspiciously long probe or -// foward shifts sequences are encounted. +// early (before its capacity is exceeded) when suspiciously long probe or +// forward shifts sequences are encountered. // // With this algorithm in place it would be possible to turn a CPU attack into -// a memory attack due to the agressive resizing. To prevent that the +// a memory attack due to the aggressive resizing. To prevent that the // adaptive behavior only triggers when the map occupancy is half the maximum occupancy. -// This reduces the effectivenes of the algorithm but also makes it completelly safe. +// This reduces the effectiveness of the algorithm but also makes it completely safe. // -// The previous safety measure that also prevents degenerate iteractions with +// The previous safety measure also prevents degenerate interactions with // really bad quality hash algorithms that can make normal inputs look like a // DOS attack. // From ec648a1ab3b2f3523f2243ebf051cb39f4053902 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sat, 18 Feb 2017 16:39:55 -0500 Subject: [PATCH 3/4] Fix indentation of error message So I just encountered this error for the first time. It's unclear what it means, why I encountered it, or how to fix it. But worst of all, it has a random newline and weird indentation! This commit fixes that last bit. --- src/librustc/ty/inhabitedness/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index 24ca476e5ff79..77c863a012318 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -187,7 +187,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { // which contains a Foo<((T, T), (T, T))> // which contains a Foo<(((T, T), (T, T)), ((T, T), (T, T)))> // etc. - let error = format!("reached recursion limit while checking + let error = format!("reached recursion limit while checking \ inhabitedness of `{}`", self); tcx.sess.fatal(&error); } From eee6752b971d620c2db89a3fa551d5739b29148e Mon Sep 17 00:00:00 2001 From: Mikhail Pak Date: Sun, 19 Feb 2017 11:01:02 +0100 Subject: [PATCH 4/4] Docs: Better explanation of return values for min, max functions Explain that a None is returned if the iterator is empty. --- src/libcore/iter/iterator.rs | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 3785bbe9bb0e4..0f47378aebb7c 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -1616,7 +1616,9 @@ pub trait Iterator { /// Returns the maximum element of an iterator. /// /// If several elements are equally maximum, the last element is - /// returned. + /// returned. If the iterator is empty, [`None`] is returned. + /// + /// [`None`]: ../../std/option/enum.Option.html#variant.None /// /// # Examples /// @@ -1624,8 +1626,10 @@ pub trait Iterator { /// /// ``` /// let a = [1, 2, 3]; + /// let b: Vec = Vec::new(); /// /// assert_eq!(a.iter().max(), Some(&3)); + /// assert_eq!(b.iter().max(), None); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -1642,7 +1646,9 @@ pub trait Iterator { /// Returns the minimum element of an iterator. /// /// If several elements are equally minimum, the first element is - /// returned. + /// returned. If the iterator is empty, [`None`] is returned. + /// + /// [`None`]: ../../std/option/enum.Option.html#variant.None /// /// # Examples /// @@ -1650,8 +1656,10 @@ pub trait Iterator { /// /// ``` /// let a = [1, 2, 3]; + /// let b: Vec = Vec::new(); /// /// assert_eq!(a.iter().min(), Some(&1)); + /// assert_eq!(b.iter().min(), None); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] @@ -1669,7 +1677,9 @@ pub trait Iterator { /// specified function. /// /// If several elements are equally maximum, the last element is - /// returned. + /// returned. If the iterator is empty, [`None`] is returned. + /// + /// [`None`]: ../../std/option/enum.Option.html#variant.None /// /// # Examples /// @@ -1694,7 +1704,9 @@ pub trait Iterator { /// specified comparison function. /// /// If several elements are equally maximum, the last element is - /// returned. + /// returned. If the iterator is empty, [`None`] is returned. + /// + /// [`None`]: ../../std/option/enum.Option.html#variant.None /// /// # Examples /// @@ -1719,7 +1731,9 @@ pub trait Iterator { /// specified function. /// /// If several elements are equally minimum, the first element is - /// returned. + /// returned. If the iterator is empty, [`None`] is returned. + /// + /// [`None`]: ../../std/option/enum.Option.html#variant.None /// /// # Examples /// @@ -1743,7 +1757,9 @@ pub trait Iterator { /// specified comparison function. /// /// If several elements are equally minimum, the first element is - /// returned. + /// returned. If the iterator is empty, [`None`] is returned. + /// + /// [`None`]: ../../std/option/enum.Option.html#variant.None /// /// # Examples ///