Skip to content

Rollup of 7 pull requests #34939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jul 21, 2016
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
42326ec
Add examples for VecDeque
GuillaumeGomez Jul 16, 2016
0c9a6f6
Add examples for LinkedList
GuillaumeGomez Jul 16, 2016
3b5d71e
Make .enumerate() example self-explanatory
Jul 17, 2016
6a09df9
implement AddAssign for String
oconnor663 Jul 17, 2016
ce442b4
Add debug for hash_map::{Entry, VacantEntry, OccupiedEntry}
GuillaumeGomez Jul 20, 2016
d820fcb
Remove rustdoc reference to `walk_dir`
mark-buer Jul 18, 2016
cac58ab
update the since field to 1.12.0 for String AddAssign
oconnor663 Jul 18, 2016
9b81306
use a new feature name for String AddAssign
oconnor663 Jul 18, 2016
f77bcc8
rustc: Remove soft-float from MIPS targets
alexcrichton Jul 18, 2016
4a2116b
[CSS] Fix unwanted top margin for toggle wrapper
GuillaumeGomez Jul 19, 2016
a005b2c
Rewrite/expand doc examples for `Vec::set_len`.
frewsxcv Jul 19, 2016
00e3149
Add doc examples for `Vec::{as_slice,as_mut_slice}`.
frewsxcv Jul 20, 2016
9b5db22
Add doc for btree_map types
GuillaumeGomez Jul 19, 2016
fbfee42
core: impl From<T> for Option<T>
seanmonstar Jul 14, 2016
bcbe27c
Rollup merge of #34828 - seanmonstar:into-opton, r=alexcrichton
GuillaumeGomez Jul 21, 2016
a168e30
Rollup merge of #34854 - GuillaumeGomez:linked_list_doc, r=steveklabnik
GuillaumeGomez Jul 21, 2016
705d92d
Rollup merge of #34855 - GuillaumeGomez:vec_deque_doc, r=steveklabnik
GuillaumeGomez Jul 21, 2016
9ba1792
Rollup merge of #34880 - xitep:master, r=steveklabnik
GuillaumeGomez Jul 21, 2016
4817c5e
Rollup merge of #34890 - oconnor663:addassign, r=brson
GuillaumeGomez Jul 21, 2016
271230f
Rollup merge of #34895 - mark-buer:patch-1, r=steveklabnik
GuillaumeGomez Jul 21, 2016
91fd838
Rollup merge of #34910 - alexcrichton:hard-float-mips, r=brson
GuillaumeGomez Jul 21, 2016
27876c0
Rollup merge of #34911 - frewsxcv:vec-set-len, r=steveklabnik
GuillaumeGomez Jul 21, 2016
d62f8dd
Rollup merge of #34919 - GuillaumeGomez:btree_map_doc, r=steveklabnik
GuillaumeGomez Jul 21, 2016
3f3dabb
Rollup merge of #34921 - GuillaumeGomez:css_fix, r=steveklabnik
GuillaumeGomez Jul 21, 2016
1006f79
Rollup merge of #34930 - frewsxcv:vec-as-slice, r=steveklabnik
GuillaumeGomez Jul 21, 2016
22a14a8
Rollup merge of #34937 - GuillaumeGomez:hash_map_entry_debug, r=apase…
GuillaumeGomez Jul 21, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/doc/book/loops.md
Original file line number Diff line number Diff line change
@@ -105,19 +105,19 @@ When you need to keep track of how many times you already looped, you can use th
#### On ranges:

```rust
for (i, j) in (5..10).enumerate() {
println!("i = {} and j = {}", i, j);
for (index, value) in (5..10).enumerate() {
println!("index = {} and value = {}", index, value);
}
```

Outputs:

```text
i = 0 and j = 5
i = 1 and j = 6
i = 2 and j = 7
i = 3 and j = 8
i = 4 and j = 9
index = 0 and value = 5
index = 1 and value = 6
index = 2 and value = 7
index = 3 and value = 8
index = 4 and value = 9
```

Don't forget to add the parentheses around the range.
191 changes: 189 additions & 2 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
@@ -313,6 +313,10 @@ pub struct RangeMut<'a, K: 'a, V: 'a> {
}

/// A view into a single entry in a map, which may either be vacant or occupied.
/// This enum is constructed from the [`entry`] method on [`BTreeMap`].
///
/// [`BTreeMap`]: struct.BTreeMap.html
/// [`entry`]: struct.BTreeMap.html#method.entry
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Entry<'a, K: 'a, V: 'a> {
/// A vacant Entry
@@ -340,7 +344,9 @@ impl<'a, K: 'a + Debug + Ord, V: 'a + Debug> Debug for Entry<'a, K, V> {
}
}

/// A vacant Entry.
/// A vacant Entry. It is part of the [`Entry`] enum.
///
/// [`Entry`]: enum.Entry.html
#[stable(feature = "rust1", since = "1.0.0")]
pub struct VacantEntry<'a, K: 'a, V: 'a> {
key: K,
@@ -360,7 +366,9 @@ impl<'a, K: 'a + Debug + Ord, V: 'a> Debug for VacantEntry<'a, K, V> {
}
}

/// An occupied Entry.
/// An occupied Entry. It is part of the [`Entry`] enum.
///
/// [`Entry`]: enum.Entry.html
#[stable(feature = "rust1", since = "1.0.0")]
pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
handle: Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::KV>,
@@ -1890,6 +1898,17 @@ impl<K, V> BTreeMap<K, V> {
impl<'a, K: Ord, V> Entry<'a, K, V> {
/// Ensures a value is in the entry by inserting the default if empty, and returns
/// a mutable reference to the value in the entry.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// map.entry("poneyland").or_insert(12);
///
/// assert_eq!(map["poneyland"], 12);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn or_insert(self, default: V) -> &'a mut V {
match self {
@@ -1900,6 +1919,19 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {

/// Ensures a value is in the entry by inserting the result of the default function if empty,
/// and returns a mutable reference to the value in the entry.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
///
/// let mut map: BTreeMap<&str, String> = BTreeMap::new();
/// let s = "hoho".to_owned();
///
/// map.entry("poneyland").or_insert_with(|| s);
///
/// assert_eq!(map["poneyland"], "hoho".to_owned());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
match self {
@@ -1909,6 +1941,15 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
}

/// Returns a reference to this entry's key.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// assert_eq!(map.entry("poneyland").key(), &"poneyland");
/// ```
#[stable(feature = "map_entry_keys", since = "1.10.0")]
pub fn key(&self) -> &K {
match *self {
@@ -1921,19 +1962,58 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
/// Gets a reference to the key that would be used when inserting a value
/// through the VacantEntry.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// assert_eq!(map.entry("poneyland").key(), &"poneyland");
/// ```
#[stable(feature = "map_entry_keys", since = "1.10.0")]
pub fn key(&self) -> &K {
&self.key
}

/// Take ownership of the key.
///
/// # Examples
///
/// ```
/// #![feature(map_entry_recover_keys)]
///
/// use std::collections::BTreeMap;
/// use std::collections::btree_map::Entry;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
///
/// if let Entry::Vacant(v) = map.entry("poneyland") {
/// v.into_key();
/// }
/// ```
#[unstable(feature = "map_entry_recover_keys", issue = "34285")]
pub fn into_key(self) -> K {
self.key
}

/// Sets the value of the entry with the VacantEntry's key,
/// and returns a mutable reference to it.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
///
/// let mut count: BTreeMap<&str, usize> = BTreeMap::new();
///
/// // count the number of occurrences of letters in the vec
/// for x in vec!["a","b","a","c","a","b"] {
/// *count.entry(x).or_insert(0) += 1;
/// }
///
/// assert_eq!(count["a"], 3);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn insert(self, value: V) -> &'a mut V {
*self.length += 1;
@@ -1979,43 +2059,150 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {

impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
/// Gets a reference to the key in the entry.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// map.entry("poneyland").or_insert(12);
/// assert_eq!(map.entry("poneyland").key(), &"poneyland");
/// ```
#[stable(feature = "map_entry_keys", since = "1.10.0")]
pub fn key(&self) -> &K {
self.handle.reborrow().into_kv().0
}

/// Take ownership of the key and value from the map.
///
/// # Examples
///
/// ```
/// #![feature(map_entry_recover_keys)]
///
/// use std::collections::BTreeMap;
/// use std::collections::btree_map::Entry;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// map.entry("poneyland").or_insert(12);
///
/// if let Entry::Occupied(o) = map.entry("poneyland") {
/// // We delete the entry from the map.
/// o.remove_pair();
/// }
///
/// // If now try to get the value, it will panic:
/// // println!("{}", map["poneyland"]);
/// ```
#[unstable(feature = "map_entry_recover_keys", issue = "34285")]
pub fn remove_pair(self) -> (K, V) {
self.remove_kv()
}

/// Gets a reference to the value in the entry.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// use std::collections::btree_map::Entry;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// map.entry("poneyland").or_insert(12);
///
/// if let Entry::Occupied(o) = map.entry("poneyland") {
/// assert_eq!(o.get(), &12);
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn get(&self) -> &V {
self.handle.reborrow().into_kv().1
}

/// Gets a mutable reference to the value in the entry.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// use std::collections::btree_map::Entry;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// map.entry("poneyland").or_insert(12);
///
/// assert_eq!(map["poneyland"], 12);
/// if let Entry::Occupied(mut o) = map.entry("poneyland") {
/// *o.get_mut() += 10;
/// }
/// assert_eq!(map["poneyland"], 22);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn get_mut(&mut self) -> &mut V {
self.handle.kv_mut().1
}

/// Converts the entry into a mutable reference to its value.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// use std::collections::btree_map::Entry;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// map.entry("poneyland").or_insert(12);
///
/// assert_eq!(map["poneyland"], 12);
/// if let Entry::Occupied(o) = map.entry("poneyland") {
/// *o.into_mut() += 10;
/// }
/// assert_eq!(map["poneyland"], 22);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn into_mut(self) -> &'a mut V {
self.handle.into_kv_mut().1
}

/// Sets the value of the entry with the OccupiedEntry's key,
/// and returns the entry's old value.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// use std::collections::btree_map::Entry;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// map.entry("poneyland").or_insert(12);
///
/// if let Entry::Occupied(mut o) = map.entry("poneyland") {
/// assert_eq!(o.insert(15), 12);
/// }
/// assert_eq!(map["poneyland"], 15);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn insert(&mut self, value: V) -> V {
mem::replace(self.get_mut(), value)
}

/// Takes the value of the entry out of the map, and returns it.
///
/// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// use std::collections::btree_map::Entry;
///
/// let mut map: BTreeMap<&str, usize> = BTreeMap::new();
/// map.entry("poneyland").or_insert(12);
///
/// if let Entry::Occupied(o) = map.entry("poneyland") {
/// assert_eq!(o.remove(), 12);
/// }
/// // If we try to get "poneyland"'s value, it'll panic:
/// // println!("{}", map["poneyland"]);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn remove(self) -> V {
self.remove_kv().1
74 changes: 65 additions & 9 deletions src/libcollections/linked_list.rs
Original file line number Diff line number Diff line change
@@ -172,6 +172,14 @@ impl<T> Default for LinkedList<T> {

impl<T> LinkedList<T> {
/// Creates an empty `LinkedList`.
///
/// # Examples
///
/// ```
/// use std::collections::LinkedList;
///
/// let list: LinkedList<u32> = LinkedList::new();
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new() -> Self {
@@ -226,6 +234,24 @@ impl<T> LinkedList<T> {
}

/// Provides a forward iterator.
///
/// # Examples
///
/// ```
/// use std::collections::LinkedList;
///
/// let mut list: LinkedList<u32> = LinkedList::new();
///
/// list.push_back(0);
/// list.push_back(1);
/// list.push_back(2);
///
/// let mut iter = list.iter();
/// assert_eq!(iter.next(), Some(&0));
/// assert_eq!(iter.next(), Some(&1));
/// assert_eq!(iter.next(), Some(&2));
/// assert_eq!(iter.next(), None);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter(&self) -> Iter<T> {
@@ -238,6 +264,28 @@ impl<T> LinkedList<T> {
}

/// Provides a forward iterator with mutable references.
///
/// # Examples
///
/// ```
/// use std::collections::LinkedList;
///
/// let mut list: LinkedList<u32> = LinkedList::new();
///
/// list.push_back(0);
/// list.push_back(1);
/// list.push_back(2);
///
/// for element in list.iter_mut() {
/// *element += 10;
/// }
///
/// let mut iter = list.iter();
/// assert_eq!(iter.next(), Some(&10));
/// assert_eq!(iter.next(), Some(&11));
/// assert_eq!(iter.next(), Some(&12));
/// assert_eq!(iter.next(), None);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter_mut(&mut self) -> IterMut<T> {
@@ -289,7 +337,6 @@ impl<T> LinkedList<T> {
///
/// dl.push_back(3);
/// assert_eq!(dl.len(), 3);
///
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -316,7 +363,6 @@ impl<T> LinkedList<T> {
/// dl.clear();
/// assert_eq!(dl.len(), 0);
/// assert_eq!(dl.front(), None);
///
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -326,6 +372,23 @@ impl<T> LinkedList<T> {

/// Returns `true` if the `LinkedList` contains an element equal to the
/// given value.
///
/// # Examples
///
/// ```
/// #![feature(linked_list_contains)]
///
/// use std::collections::LinkedList;
///
/// let mut list: LinkedList<u32> = LinkedList::new();
///
/// list.push_back(0);
/// list.push_back(1);
/// list.push_back(2);
///
/// assert_eq!(list.contains(&0), true);
/// assert_eq!(list.contains(&10), false);
/// ```
#[unstable(feature = "linked_list_contains", reason = "recently added",
issue = "32630")]
pub fn contains(&self, x: &T) -> bool
@@ -347,7 +410,6 @@ impl<T> LinkedList<T> {
///
/// dl.push_front(1);
/// assert_eq!(dl.front(), Some(&1));
///
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -374,7 +436,6 @@ impl<T> LinkedList<T> {
/// Some(x) => *x = 5,
/// }
/// assert_eq!(dl.front(), Some(&5));
///
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -395,7 +456,6 @@ impl<T> LinkedList<T> {
///
/// dl.push_back(1);
/// assert_eq!(dl.back(), Some(&1));
///
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -422,7 +482,6 @@ impl<T> LinkedList<T> {
/// Some(x) => *x = 5,
/// }
/// assert_eq!(dl.back(), Some(&5));
///
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
@@ -446,7 +505,6 @@ impl<T> LinkedList<T> {
///
/// dl.push_front(1);
/// assert_eq!(dl.front().unwrap(), &1);
///
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn push_front(&mut self, elt: T) {
@@ -471,9 +529,7 @@ impl<T> LinkedList<T> {
/// assert_eq!(d.pop_front(), Some(3));
/// assert_eq!(d.pop_front(), Some(1));
/// assert_eq!(d.pop_front(), None);
///
/// ```
///
#[stable(feature = "rust1", since = "1.0.0")]
pub fn pop_front(&mut self) -> Option<T> {
self.pop_front_node().map(Node::into_element)
10 changes: 9 additions & 1 deletion src/libcollections/string.rs
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ use core::fmt;
use core::hash;
use core::iter::FromIterator;
use core::mem;
use core::ops::{self, Add, Index, IndexMut};
use core::ops::{self, Add, AddAssign, Index, IndexMut};
use core::ptr;
use core::str::pattern::Pattern;
use rustc_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER};
@@ -1565,6 +1565,14 @@ impl<'a> Add<&'a str> for String {
}
}

#[stable(feature = "stringaddassign", since = "1.12.0")]
impl<'a> AddAssign<&'a str> for String {
#[inline]
fn add_assign(&mut self, other: &str) {
self.push_str(other);
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl ops::Index<ops::Range<usize>> for String {
type Output = str;
48 changes: 46 additions & 2 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
@@ -541,6 +541,14 @@ impl<T> Vec<T> {
/// Extracts a slice containing the entire vector.
///
/// Equivalent to `&s[..]`.
///
/// # Examples
///
/// ```
/// use std::io::{self, Write};
/// let buffer = vec![1, 2, 3, 5, 8];
/// io::sink().write(buffer.as_slice()).unwrap();
/// ```
#[inline]
#[stable(feature = "vec_as_slice", since = "1.7.0")]
pub fn as_slice(&self) -> &[T] {
@@ -550,6 +558,14 @@ impl<T> Vec<T> {
/// Extracts a mutable slice of the entire vector.
///
/// Equivalent to `&mut s[..]`.
///
/// # Examples
///
/// ```
/// use std::io::{self, Read};
/// let mut buffer = vec![0; 3];
/// io::repeat(0b101).read_exact(buffer.as_mut_slice()).unwrap();
/// ```
#[inline]
#[stable(feature = "vec_as_slice", since = "1.7.0")]
pub fn as_mut_slice(&mut self) -> &mut [T] {
@@ -565,9 +581,37 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// let mut v = vec![1, 2, 3, 4];
/// use std::ptr;
///
/// let mut vec = vec!['r', 'u', 's', 't'];
///
/// unsafe {
/// ptr::drop_in_place(&mut vec[3]);
/// vec.set_len(3);
/// }
/// assert_eq!(vec, ['r', 'u', 's']);
/// ```
///
/// In this example, there is a memory leak since the memory locations
/// owned by the vector were not freed prior to the `set_len` call:
///
/// ```
/// let mut vec = vec!['r', 'u', 's', 't'];
///
/// unsafe {
/// vec.set_len(0);
/// }
/// ```
///
/// In this example, the vector gets expanded from zero to four items
/// without any memory allocations occurring, resulting in vector
/// values of unallocated memory:
///
/// ```
/// let mut vec: Vec<char> = Vec::new();
///
/// unsafe {
/// v.set_len(1);
/// vec.set_len(4);
/// }
/// ```
#[inline]
72 changes: 71 additions & 1 deletion src/libcollections/vec_deque.rs
Original file line number Diff line number Diff line change
@@ -365,12 +365,28 @@ impl<T> VecDeque<T> {

impl<T> VecDeque<T> {
/// Creates an empty `VecDeque`.
///
/// # Examples
///
/// ```
/// use std::collections::VecDeque;
///
/// let vector: VecDeque<u32> = VecDeque::new();
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new() -> VecDeque<T> {
VecDeque::with_capacity(INITIAL_CAPACITY)
}

/// Creates an empty `VecDeque` with space for at least `n` elements.
///
/// # Examples
///
/// ```
/// use std::collections::VecDeque;
///
/// let vector: VecDeque<u32> = VecDeque::with_capacity(10);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn with_capacity(n: usize) -> VecDeque<T> {
// +1 since the ringbuffer always leaves one space empty
@@ -696,6 +712,25 @@ impl<T> VecDeque<T> {

/// Returns a pair of slices which contain, in order, the contents of the
/// `VecDeque`.
///
/// # Examples
///
/// ```
/// use std::collections::VecDeque;
///
/// let mut vector: VecDeque<u32> = VecDeque::new();
///
/// vector.push_back(0);
/// vector.push_back(1);
/// vector.push_back(2);
///
/// assert_eq!(vector.as_slices(), (&[0u32, 1, 2] as &[u32], &[] as &[u32]));
///
/// vector.push_front(10);
/// vector.push_front(9);
///
/// assert_eq!(vector.as_slices(), (&[9u32, 10] as &[u32], &[0u32, 1, 2] as &[u32]));
/// ```
#[inline]
#[stable(feature = "deque_extras_15", since = "1.5.0")]
pub fn as_slices(&self) -> (&[T], &[T]) {
@@ -715,6 +750,24 @@ impl<T> VecDeque<T> {

/// Returns a pair of slices which contain, in order, the contents of the
/// `VecDeque`.
///
/// # Examples
///
/// ```
/// use std::collections::VecDeque;
///
/// let mut vector: VecDeque<u32> = VecDeque::new();
///
/// vector.push_back(0);
/// vector.push_back(1);
///
/// vector.push_front(10);
/// vector.push_front(9);
///
/// vector.as_mut_slices().0[0] = 42;
/// vector.as_mut_slices().1[0] = 24;
/// assert_eq!(vector.as_slices(), (&[42u32, 10] as &[u32], &[24u32, 1] as &[u32]));
/// ```
#[inline]
#[stable(feature = "deque_extras_15", since = "1.5.0")]
pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T]) {
@@ -789,7 +842,7 @@ impl<T> VecDeque<T> {
///
/// ```
/// use std::collections::VecDeque;
///
/// let mut v: VecDeque<_> = vec![1, 2, 3].into_iter().collect();
/// assert_eq!(vec![3].into_iter().collect::<VecDeque<_>>(), v.drain(2..).collect());
/// assert_eq!(vec![1, 2].into_iter().collect::<VecDeque<_>>(), v);
@@ -875,6 +928,22 @@ impl<T> VecDeque<T> {

/// Returns `true` if the `VecDeque` contains an element equal to the
/// given value.
///
/// # Examples
///
/// ```
/// #![feature(vec_deque_contains)]
///
/// use std::collections::VecDeque;
///
/// let mut vector: VecDeque<u32> = VecDeque::new();
///
/// vector.push_back(0);
/// vector.push_back(1);
///
/// assert_eq!(vector.contains(&1), true);
/// assert_eq!(vector.contains(&10), false);
/// ```
#[unstable(feature = "vec_deque_contains", reason = "recently added",
issue = "32630")]
pub fn contains(&self, x: &T) -> bool
@@ -1404,6 +1473,7 @@ impl<T> VecDeque<T> {
/// Returns `None` if `index` is out of bounds.
///
/// # Examples
///
/// ```
/// use std::collections::VecDeque;
///
8 changes: 8 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
@@ -142,6 +142,7 @@
use self::Option::*;

use clone::Clone;
use convert::From;
use default::Default;
use iter::ExactSizeIterator;
use iter::{Iterator, DoubleEndedIterator, FromIterator, IntoIterator};
@@ -754,6 +755,13 @@ impl<'a, T> IntoIterator for &'a mut Option<T> {
}
}

#[stable(since = "1.12.0", feature = "option_from")]
impl<T> From<T> for Option<T> {
fn from(val: T) -> Option<T> {
Some(val)
}
}

/////////////////////////////////////////////////////////////////////////////
// The Option Iterators
/////////////////////////////////////////////////////////////////////////////
2 changes: 1 addition & 1 deletion src/librustc_back/target/mips_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ pub fn target() -> Target {
target_vendor: "unknown".to_string(),
options: TargetOptions {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+soft-float".to_string(),
features: "+mips32r2".to_string(),
max_atomic_width: 32,
..super::linux_base::opts()
},
5 changes: 4 additions & 1 deletion src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
@@ -636,8 +636,11 @@ span.since {
margin-right: 5px;
}

.enum > .toggle-wrapper > .collapse-toggle, .struct > .toggle-wrapper > .collapse-toggle {
.toggle-wrapper > .collapse-toggle {
left: 0;
}

.variant + .toggle-wrapper > a {
margin-top: 5px;
}

33 changes: 33 additions & 0 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
@@ -1351,13 +1351,37 @@ pub enum Entry<'a, K: 'a, V: 'a> {
),
}

#[stable(feature= "debug_hash_map", since = "1.12.0")]
impl<'a, K: 'a + Debug, V: 'a + Debug> Debug for Entry<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Vacant(ref v) => f.debug_tuple("Entry")
.field(v)
.finish(),
Occupied(ref o) => f.debug_tuple("Entry")
.field(o)
.finish(),
}
}
}

/// A view into a single occupied location in a HashMap.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
key: Option<K>,
elem: FullBucket<K, V, &'a mut RawTable<K, V>>,
}

#[stable(feature= "debug_hash_map", since = "1.12.0")]
impl<'a, K: 'a + Debug, V: 'a + Debug> Debug for OccupiedEntry<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("OccupiedEntry")
.field("key", self.key())
.field("value", self.get())
.finish()
}
}

/// A view into a single empty location in a HashMap.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct VacantEntry<'a, K: 'a, V: 'a> {
@@ -1366,6 +1390,15 @@ pub struct VacantEntry<'a, K: 'a, V: 'a> {
elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
}

#[stable(feature= "debug_hash_map", since = "1.12.0")]
impl<'a, K: 'a + Debug, V: 'a> Debug for VacantEntry<'a, K, V> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("VacantEntry")
.field(self.key())
.finish()
}
}

/// Possible states of a VacantEntry.
enum VacantEntryState<K, V, M> {
/// The index is occupied, but the key to insert has precedence,
4 changes: 2 additions & 2 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
@@ -791,8 +791,8 @@ impl Iterator for ReadDir {
impl DirEntry {
/// Returns the full path to the file that this entry represents.
///
/// The full path is created by joining the original path to `read_dir` or
/// `walk_dir` with the filename of this entry.
/// The full path is created by joining the original path to `read_dir`
/// with the filename of this entry.
///
/// # Examples
///