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() {}` 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 /// 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); } 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. //