Skip to content

Commit 01b6fd3

Browse files
committedJul 18, 2014
Remove examples from trait implementations. Unhide imports.
1 parent b2a02b5 commit 01b6fd3

File tree

1 file changed

+18
-154
lines changed

1 file changed

+18
-154
lines changed
 

‎src/libstd/collections/hashmap.rs

+18-154
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ impl<T: Hash + Eq> HashSet<T, RandomSipHasher> {
15511551
/// # Example
15521552
///
15531553
/// ```rust
1554-
/// # use std::collections::HashSet;
1554+
/// use std::collections::HashSet;
15551555
/// let mut set: HashSet<int> = HashSet::new();
15561556
/// ```
15571557
#[inline]
@@ -1565,7 +1565,7 @@ impl<T: Hash + Eq> HashSet<T, RandomSipHasher> {
15651565
/// # Example
15661566
///
15671567
/// ```rust
1568-
/// # use std::collections::HashSet;
1568+
/// use std::collections::HashSet;
15691569
/// let mut set: HashSet<int> = HashSet::with_capacity(10);
15701570
/// ```
15711571
#[inline]
@@ -1583,7 +1583,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
15831583
/// # Example
15841584
///
15851585
/// ```rust
1586-
/// # use std::collections::HashSet;
1586+
/// use std::collections::HashSet;
15871587
/// use std::hash::sip::SipHasher;
15881588
///
15891589
/// let h = SipHasher::new();
@@ -1606,7 +1606,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
16061606
/// # Example
16071607
///
16081608
/// ```rust
1609-
/// # use std::collections::HashSet;
1609+
/// use std::collections::HashSet;
16101610
/// use std::hash::sip::SipHasher;
16111611
///
16121612
/// let h = SipHasher::new();
@@ -1623,7 +1623,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
16231623
/// # Example
16241624
///
16251625
/// ```rust
1626-
/// # use std::collections::HashSet;
1626+
/// use std::collections::HashSet;
16271627
/// let mut set: HashSet<int> = HashSet::new();
16281628
/// set.reserve(10);
16291629
/// ```
@@ -1641,7 +1641,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
16411641
/// values hash the same, which is why we implement `Hash`.
16421642
///
16431643
/// ```rust
1644-
/// # use std::collections::HashSet;
1644+
/// use std::collections::HashSet;
16451645
/// use std::hash::Hash;
16461646
/// use std::hash::sip::SipState;
16471647
///
@@ -1682,7 +1682,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
16821682
/// # Example
16831683
///
16841684
/// ```rust
1685-
/// # use std::collections::HashSet;
1685+
/// use std::collections::HashSet;
1686+
///
16861687
/// let mut set = HashSet::new();
16871688
/// set.insert("a");
16881689
/// set.insert("b");
@@ -1703,7 +1704,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
17031704
/// # Example
17041705
///
17051706
/// ```rust
1706-
/// # use std::collections::HashSet;
1707+
/// use std::collections::HashSet;
1708+
///
17071709
/// let mut set = HashSet::new();
17081710
/// set.insert("a".to_string());
17091711
/// set.insert("b".to_string());
@@ -1725,7 +1727,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
17251727
/// # Example
17261728
///
17271729
/// ```rust
1728-
/// # use std::collections::HashSet;
1730+
/// use std::collections::HashSet;
1731+
///
17291732
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
17301733
/// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
17311734
///
@@ -1754,7 +1757,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
17541757
/// # Example
17551758
///
17561759
/// ```rust
1757-
/// # use std::collections::HashSet;
1760+
/// use std::collections::HashSet;
1761+
///
17581762
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
17591763
/// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
17601764
///
@@ -1779,7 +1783,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
17791783
/// # Example
17801784
///
17811785
/// ```rust
1782-
/// # use std::collections::HashSet;
1786+
/// use std::collections::HashSet;
1787+
///
17831788
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
17841789
/// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
17851790
///
@@ -1804,7 +1809,8 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
18041809
/// # Example
18051810
///
18061811
/// ```rust
1807-
/// # use std::collections::HashSet;
1812+
/// use std::collections::HashSet;
1813+
///
18081814
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
18091815
/// let b: HashSet<int> = [4i, 2, 3, 4].iter().map(|&x| x).collect();
18101816
///
@@ -1823,22 +1829,6 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
18231829
}
18241830

18251831
impl<T: Eq + Hash<S>, S, H: Hasher<S>> PartialEq for HashSet<T, H> {
1826-
/// Partial equality between sets.
1827-
///
1828-
/// # Example
1829-
///
1830-
/// ```rust
1831-
/// # use std::collections::HashSet;
1832-
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
1833-
/// let b: HashSet<int> = [1i, 2, 3, 4].iter().map(|&x| x).collect();
1834-
/// let c: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
1835-
///
1836-
/// assert!(a.eq(&c));
1837-
///
1838-
/// // eq and ne defines the == and != operators
1839-
/// assert!(a == c);
1840-
/// assert!(a != b);
1841-
/// ```
18421832
fn eq(&self, other: &HashSet<T, H>) -> bool {
18431833
if self.len() != other.len() { return false; }
18441834

@@ -1849,127 +1839,33 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S>> PartialEq for HashSet<T, H> {
18491839
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {}
18501840

18511841
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Collection for HashSet<T, H> {
1852-
/// Return the number of elements in the set.
1853-
///
1854-
/// # Example
1855-
///
1856-
/// ```rust
1857-
/// # use std::collections::HashSet;
1858-
/// let set: HashSet<int> = [1i, 2, 3, 2].iter().map(|&x| x).collect();
1859-
/// assert_eq!(set.len(), 3);
1860-
/// ```
18611842
fn len(&self) -> uint { self.map.len() }
18621843
}
18631844

18641845
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Mutable for HashSet<T, H> {
1865-
/// Clear the set. Keeps the allocated memory for reuse.
1866-
///
1867-
/// # Example
1868-
///
1869-
/// ```rust
1870-
/// # use std::collections::HashSet;
1871-
/// let mut set: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
1872-
/// set.clear();
1873-
/// assert!(set.is_empty());
1874-
/// ```
18751846
fn clear(&mut self) { self.map.clear() }
18761847
}
18771848

18781849
impl<T: Eq + Hash<S>, S, H: Hasher<S>> Set<T> for HashSet<T, H> {
1879-
/// Return true if `value` is contained by the set.
1880-
///
1881-
/// # Example
1882-
///
1883-
/// ```rust
1884-
/// # use std::collections::HashSet;
1885-
/// let set: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
1886-
/// assert_eq!(set.contains(&1), true);
1887-
/// assert_eq!(set.contains(&4), false);
1888-
/// ```
18891850
fn contains(&self, value: &T) -> bool { self.map.contains_key(value) }
18901851

1891-
/// Return true if the set is disjoint with `other`.
1892-
///
1893-
/// # Example
1894-
///
1895-
/// ```rust
1896-
/// # use std::collections::HashSet;
1897-
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
1898-
/// let mut b: HashSet<int> = HashSet::new();
1899-
///
1900-
/// assert_eq!(a.is_disjoint(&b), true);
1901-
/// b.insert(4);
1902-
/// assert_eq!(a.is_disjoint(&b), true);
1903-
/// b.insert(1);
1904-
/// assert_eq!(a.is_disjoint(&b), false);
1905-
/// ```
19061852
fn is_disjoint(&self, other: &HashSet<T, H>) -> bool {
19071853
self.iter().all(|v| !other.contains(v))
19081854
}
19091855

1910-
/// Return true if the set is a subset of `other`.
1911-
///
1912-
/// # Example
1913-
///
1914-
/// ```rust
1915-
/// # use std::collections::HashSet;
1916-
/// let sup: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
1917-
/// let mut set: HashSet<int> = HashSet::new();
1918-
///
1919-
/// assert_eq!(set.is_subset(&sup), true);
1920-
/// set.insert(2);
1921-
/// assert_eq!(set.is_subset(&sup), true);
1922-
/// set.insert(4);
1923-
/// assert_eq!(set.is_subset(&sup), false);
1924-
/// ```
19251856
fn is_subset(&self, other: &HashSet<T, H>) -> bool {
19261857
self.iter().all(|v| other.contains(v))
19271858
}
19281859
}
19291860

19301861
impl<T: Eq + Hash<S>, S, H: Hasher<S>> MutableSet<T> for HashSet<T, H> {
1931-
/// Insert an element.
1932-
///
1933-
/// # Example
1934-
///
1935-
/// ```rust
1936-
/// # use std::collections::HashSet;
1937-
/// let mut set = HashSet::new();
1938-
/// set.insert(2i);
1939-
/// set.insert(2i);
1940-
/// assert_eq!(set.len(), 1);
1941-
/// ```
19421862
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
19431863

1944-
/// Remove an element.
1945-
///
1946-
/// # Example
1947-
///
1948-
/// ```rust
1949-
/// # use std::collections::HashSet;
1950-
/// let mut set = HashSet::new();
1951-
/// set.insert(2i);
1952-
///
1953-
/// // Return boolean success flag.
1954-
/// assert_eq!(set.remove(&2), true);
1955-
/// assert_eq!(set.remove(&2), false);
1956-
/// ```
19571864
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
19581865
}
19591866

19601867

19611868
impl<T: Eq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
1962-
/// Implement the `Show` trait for easy output format. The values in the
1963-
/// set must also implement `Show`.
1964-
///
1965-
/// # Example
1966-
///
1967-
/// ```rust
1968-
/// # use std::collections::HashSet;
1969-
/// let a: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
1970-
/// // Will call .fmt() to print, in some order.
1971-
/// println!("{}", a);
1972-
/// ```
19731869
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
19741870
try!(write!(f, "{{"));
19751871

@@ -1983,17 +1879,6 @@ impl<T: Eq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
19831879
}
19841880

19851881
impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T, H> {
1986-
/// Build a set from an external iterator.
1987-
///
1988-
/// # Example
1989-
///
1990-
/// ```rust
1991-
/// # use std::collections::HashSet;
1992-
/// let values = vec!(1i, 2, 3);
1993-
/// let set: HashSet<int> = values.move_iter().collect();
1994-
/// let another_set: HashSet<int> = [1i, 2, 3].iter().map(|&x| x).collect();
1995-
/// assert_eq!(set, another_set);
1996-
/// ```
19971882
fn from_iter<I: Iterator<T>>(iter: I) -> HashSet<T, H> {
19981883
let (lower, _) = iter.size_hint();
19991884
let mut set = HashSet::with_capacity_and_hasher(lower, Default::default());
@@ -2003,18 +1888,6 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T,
20031888
}
20041889

20051890
impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Extendable<T> for HashSet<T, H> {
2006-
/// Extend the set with the values yielded by an iterator.
2007-
///
2008-
/// # Example
2009-
///
2010-
/// ```rust
2011-
/// # use std::collections::HashSet;
2012-
/// let values = vec!(1i, 2, 3);
2013-
/// let mut set = HashSet::new();
2014-
/// set.insert(0i);
2015-
/// set.extend(values.move_iter());
2016-
/// assert_eq!(set.len(), 4);
2017-
/// ```
20181891
fn extend<I: Iterator<T>>(&mut self, mut iter: I) {
20191892
for k in iter {
20201893
self.insert(k);
@@ -2023,15 +1896,6 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Extendable<T> for HashSet<T, H>
20231896
}
20241897

20251898
impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Default for HashSet<T, H> {
2026-
/// Create a default set.
2027-
///
2028-
/// # Example
2029-
///
2030-
/// ```rust
2031-
/// # use std::collections::HashSet;
2032-
/// use std::default::Default;
2033-
/// let mut set: HashSet<int> = Default::default();
2034-
/// ```
20351899
fn default() -> HashSet<T, H> {
20361900
HashSet::with_hasher(Default::default())
20371901
}

5 commit comments

Comments
 (5)

bors commented on Jul 19, 2014

@bors
Collaborator

bors commented on Jul 19, 2014

@bors
Collaborator

merging treeman/rust/hashset-doc = 01b6fd3 into auto

bors commented on Jul 19, 2014

@bors
Collaborator

treeman/rust/hashset-doc = 01b6fd3 merged ok, testing candidate = 793b142

bors commented on Jul 19, 2014

@bors
Collaborator

fast-forwarding master to auto = 793b142

Please sign in to comment.