@@ -415,6 +415,16 @@ impl<T: Ord> BTreeSet<T> {
415415 /// The value may be any borrowed form of the set's value type,
416416 /// but the ordering on the borrowed form *must* match the
417417 /// ordering on the value type.
418+ ///
419+ /// # Examples
420+ ///
421+ /// ```
422+ /// use std::collections::BTreeSet;
423+ ///
424+ /// let set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
425+ /// assert_eq!(set.get(&2), Some(&2));
426+ /// assert_eq!(set.get(&4), None);
427+ /// ```
418428 #[ stable( feature = "set_recovery" , since = "1.9.0" ) ]
419429 pub fn get < Q : ?Sized > ( & self , value : & Q ) -> Option < & T >
420430 where T : Borrow < Q > ,
@@ -540,6 +550,19 @@ impl<T: Ord> BTreeSet<T> {
540550
541551 /// Adds a value to the set, replacing the existing value, if any, that is equal to the given
542552 /// one. Returns the replaced value.
553+ ///
554+ /// # Examples
555+ ///
556+ /// ```
557+ /// use std::collections::BTreeSet;
558+ ///
559+ /// let mut set = BTreeSet::new();
560+ /// set.insert(Vec::<i32>::new());
561+ ///
562+ /// assert_eq!(set.get(&[][..]).unwrap().capacity(), 0);
563+ /// set.replace(Vec::with_capacity(10));
564+ /// assert_eq!(set.get(&[][..]).unwrap().capacity(), 10);
565+ /// ```
543566 #[ stable( feature = "set_recovery" , since = "1.9.0" ) ]
544567 pub fn replace ( & mut self , value : T ) -> Option < T > {
545568 Recover :: replace ( & mut self . map , value)
@@ -576,6 +599,16 @@ impl<T: Ord> BTreeSet<T> {
576599 /// The value may be any borrowed form of the set's value type,
577600 /// but the ordering on the borrowed form *must* match the
578601 /// ordering on the value type.
602+ ///
603+ /// # Examples
604+ ///
605+ /// ```
606+ /// use std::collections::BTreeSet;
607+ ///
608+ /// let mut set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
609+ /// assert_eq!(set.take(&2), Some(2));
610+ /// assert_eq!(set.take(&2), None);
611+ /// ```
579612 #[ stable( feature = "set_recovery" , since = "1.9.0" ) ]
580613 pub fn take < Q : ?Sized > ( & mut self , value : & Q ) -> Option < T >
581614 where T : Borrow < Q > ,
0 commit comments