//! complexity. A priority queue can also be converted to a sorted vector in-place, allowing it to
//! be used for an `O(n log n)` in-place heapsort.
//!
-//! # Example
+//! # Examples
//!
//! This is a larger example which implements [Dijkstra's algorithm][dijkstra]
//! to solve the [shortest path problem][sssp] on a [directed graph][dir_graph].
impl<T: Ord> BinaryHeap<T> {
/// Creates an empty `BinaryHeap` as a max-heap.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// so that the `BinaryHeap` does not have to be reallocated
/// until it contains at least that many values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// Creates a `BinaryHeap` from a vector. This is sometimes called
/// `heapifying` the vector.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// An iterator visiting all values in underlying vector, in
/// arbitrary order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// the binary heap in arbitrary order. The binary heap cannot be used
/// after calling this.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// Returns the greatest item in a queue, or `None` if it is empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// Returns the number of elements the queue can hold without reallocating.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
///
/// Panics if the new capacity overflows `uint`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
///
/// Panics if the new capacity overflows `uint`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// Removes the greatest item from a queue and returns it, or `None` if it
/// is empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// Pushes an item onto the queue.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// Pushes an item onto a queue then pops the greatest item off the queue in
/// an optimized fashion.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// an optimized fashion. The push is done regardless of whether the queue
/// was empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// Consumes the `BinaryHeap` and returns the underlying vector
/// in arbitrary order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
/// Consumes the `BinaryHeap` and returns a vector in sorted
/// (ascending) order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
//! Collections implemented with bit vectors.
//!
-//! # Example
+//! # Examples
//!
//! This is a simple example of the [Sieve of Eratosthenes][sieve]
//! which calculates prime numbers up to a given limit.
/// The bitvector type.
///
-/// # Example
+/// # Examples
///
/// ```rust
/// use collections::Bitv;
/// Creates an empty `Bitv`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
/// Creates a `Bitv` that holds `nbits` elements, setting each element
/// to `init`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
///
/// Panics if `i` is out of bounds.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
///
/// Panics if `i` is out of bounds.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
/// Sets all bits to 1.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
/// Flips all bits.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
///
/// Panics if the bitvectors are of different lengths.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
///
/// Panics if the bitvectors are of different lengths.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
///
/// Panics if the bitvectors are of different length.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
/// Returns `true` if all bits are 1.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
/// Returns an iterator over the elements of the vector in order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
/// Returns `true` if all bits are 0.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
/// Returns `true` if any bit is 1.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
/// size of the `Bitv` is not a multiple of eight then trailing bits
/// will be filled-in with `false`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
/// Transforms `self` into a `Vec<bool>` by turning each bit into a `bool`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
///
/// Panics if the `Bitv` and slice are of different length.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
/// If `len` is greater than the vector's current length, this has no
/// effect.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
/// Grows the vector to be able to store `size` bits without resizing.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
/// Returns the capacity in bits for this bit vector. Inserting any
/// element less than this amount will not trigger a resizing.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
/// Grows the `Bitv` in-place, adding `n` copies of `value` to the `Bitv`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
///
/// Assert if empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::bitv;
/// Pushes a `bool` onto the end.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::Bitv;
/// with the most significant bits of each byte coming first. Each
/// bit becomes `true` if equal to 1 or `false` if equal to 0.
///
-/// # Example
+/// # Examples
///
/// ```
/// use std::collections::bitv;
/// Creates a `Bitv` of the specified length where the value at each
/// index is `f(index)`.
///
-/// # Example
+/// # Examples
///
/// ```
/// use std::collections::bitv::from_fn;
/// set of objects is proportional to the maximum of the objects when viewed
/// as a `uint`.
///
-/// # Example
+/// # Examples
///
/// ```
/// use std::collections::{BitvSet, Bitv};
impl BitvSet {
/// Creates a new bit vector set with initially no contents.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Creates a new bit vector set with initially no contents, able to
/// hold `nbits` elements without resizing.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Creates a new bit vector set from the given bit vector.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::{bitv, BitvSet};
/// Returns the capacity in bits for this bit vector. Inserting any
/// element less than this amount will not trigger a resizing.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Grows the underlying vector to be able to store `size` bits.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Consumes this set to return the underlying bit vector.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Returns a reference to the underlying bit vector.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Truncates the underlying vector to the least length required.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Iterator over each u32 stored in the `BitvSet`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Iterator over each u32 stored in `self` union `other`.
/// See [union_with](#method.union_with) for an efficient in-place version.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Iterator over each uint stored in `self` intersect `other`.
/// See [intersect_with](#method.intersect_with) for an efficient in-place version.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Iterator over each uint stored in the `self` setminus `other`.
/// See [difference_with](#method.difference_with) for an efficient in-place version.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// See [symmetric_difference_with](#method.symmetric_difference_with) for
/// an efficient in-place version.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Unions in-place with the specified other bit vector.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Intersects in-place with the specified other bit vector.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Makes this bit vector the difference with the specified other bit vector
/// in-place.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Makes this bit vector the symmetric difference with the specified other
/// bit vector in-place.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BitvSet;
/// Clears the map, removing all values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// The key may be any borrowed form of the map's key type, but the ordering
/// on the borrowed form *must* match the ordering on the key type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// The key may be any borrowed form of the map's key type, but the ordering
/// on the borrowed form *must* match the ordering on the key type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// The key may be any borrowed form of the map's key type, but the ordering
/// on the borrowed form *must* match the ordering on the key type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// Inserts a key-value pair from the map. If the key already had a value
/// present in the map, that value is returned. Otherwise, `None` is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// The key may be any borrowed form of the map's key type, but the ordering
/// on the borrowed form *must* match the ordering on the key type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// Gets an iterator over the keys of the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// Gets an iterator over the values of the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// Return the number of elements in the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
/// Return true if the map contains no elements.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeMap;
impl<T: Ord> BTreeSet<T> {
/// Visits the values representing the difference, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Visits the values representing the symmetric difference, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Visits the values representing the intersection, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Visits the values representing the union, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Return the number of elements in the set
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Returns true if the set contains no elements
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Clears the set, removing all values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// but the ordering on the borrowed form *must* match the
/// ordering on the value type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Returns `true` if the set has no elements in common with `other`.
/// This is equivalent to checking for an empty intersection.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Returns `true` if the set is a subset of another.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Returns `true` if the set is a superset of another.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// Adds a value to the set. Returns `true` if the value was not already
/// present in the set.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
/// but the ordering on the borrowed form *must* match the
/// ordering on the value type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::BTreeSet;
///
/// If the list is empty, does nothing.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::DList;
///
/// If the list is empty, does nothing.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::DList;
///
/// This operation should compute in O(1) time.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::DList;
///
/// This operation should compute in O(1) time.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::DList;
///
/// This operation should compute in O(N) time.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::DList;
/// Appends an element to the back of a list
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::DList;
/// Removes the last element from a list and returns it, or `None` if
/// it is empty.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::DList;
//! This module provides a generic way to compute the hash of a value. The
//! simplest way to make a type hashable is to use `#[deriving(Hash)]`:
//!
-//! # Example
+//! # Examples
//!
//! ```rust
//! use std::hash;
/// Retrieves an element in the `RingBuf` by index.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::RingBuf;
/// Retrieves an element in the `RingBuf` mutably by index.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::RingBuf;
///
/// Fails if there is no element with either index.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::RingBuf;
/// Returns the number of elements the `RingBuf` can hold without
/// reallocating.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
///
/// Panics if the new capacity overflows `uint`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
///
/// Panics if the new capacity overflows `uint`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Returns a front-to-back iterator.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::RingBuf;
/// Returns a front-to-back iterator which returns mutable references.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::RingBuf;
/// Returns the number of elements in the `RingBuf`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Returns true if the buffer contains no elements
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Clears the buffer, removing all values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Provides a reference to the front element, or `None` if the sequence is
/// empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Provides a mutable reference to the front element, or `None` if the
/// sequence is empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Provides a reference to the back element, or `None` if the sequence is
/// empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Provides a mutable reference to the back element, or `None` if the
/// sequence is empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Removes the first element and returns it, or `None` if the sequence is
/// empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Inserts an element first in the sequence.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::RingBuf;
/// Appends an element to the back of a buffer
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::RingBuf;
/// Removes the last element from a buffer and returns it, or `None` if
/// it is empty.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// use std::collections::RingBuf;
/// Creates an iterator that yields every possible permutation of the
/// vector in succession.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let v = [1i, 2, 3];
/// }
/// ```
///
- /// # Example 2: iterating through permutations one by one.
+ /// Iterating through permutations one by one.
///
/// ```rust
/// let v = [1i, 2, 3];
///
/// This is equivalent to `self.sort_by(|a, b| a.cmp(b))`.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let mut v = [-5i, 4, 1, -3, 2];
/// This sort is `O(n log n)` worst-case and stable, but allocates
/// approximately `2 * n`, where `n` is the length of `self`.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let mut v = [5i, 4, 1, 3, 2];
/// * start - The index into `src` to start copying from
/// * end - The index into `src` to stop copying from
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let mut a = [1i, 2, 3, 4, 5];
pub trait StrVector for Sized? {
/// Concatenates a vector of strings.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let first = "Restaurant at the End of the".to_string();
/// Concatenates a vector of strings, placing a given separator between each.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let first = "Roast".to_string();
///
/// The original string with all occurrences of `from` replaced with `to`.
///
-/// # Example
+/// # Examples
///
/// ```rust
/// use std::str;
impl<'a> MaybeOwned<'a> {
/// Returns `true` if this `MaybeOwned` wraps an owned string.
///
- /// # Example
+ /// # Examples
///
/// ``` ignore
/// let string = String::from_str("orange");
/// Returns `true` if this `MaybeOwned` wraps a borrowed string.
///
- /// # Example
+ /// # Examples
///
/// ``` ignore
/// let string = "orange";
#[deprecated = "use std::borrow::IntoCow"]
#[allow(deprecated)]
impl<'a> IntoMaybeOwned<'a> for String {
- /// # Example
+ /// # Examples
///
/// ``` ignore
/// let owned_string = String::from_str("orange");
#[deprecated = "use std::borrow::IntoCow"]
#[allow(deprecated)]
impl<'a> IntoMaybeOwned<'a> for &'a str {
- /// # Example
+ /// # Examples
///
/// ``` ignore
/// let string = "orange";
#[allow(deprecated)]
#[deprecated = "use std::borrow::IntoCow"]
impl<'a> IntoMaybeOwned<'a> for MaybeOwned<'a> {
- /// # Example
+ /// # Examples
///
/// ``` ignore
/// let str = "orange";
///
/// The original string with all occurrences of `from` replaced with `to`.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let s = "Do you know the muffin man,
impl String {
/// Creates a new string buffer initialized with the empty string.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::new();
/// The string will be able to hold exactly `capacity` bytes without
/// reallocating. If `capacity` is 0, the string will not allocate.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::with_capacity(10);
/// Creates a new string buffer from the given string.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let s = String::from_str("hello");
/// Returns `Err` with the original vector if the vector contains invalid
/// UTF-8.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let hello_vec = vec![104, 101, 108, 108, 111];
/// Converts a vector of bytes to a new UTF-8 string.
/// Any invalid UTF-8 sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let input = b"Hello \xF0\x90\x80World";
/// Decode a UTF-16 encoded vector `v` into a `String`, returning `None`
/// if `v` contains any invalid data.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// // 𝄞music
/// Decode a UTF-16 encoded vector `v` into a string, replacing
/// invalid data with the replacement character (U+FFFD).
///
- /// # Example
+ /// # Examples
+ ///
/// ```rust
/// // 𝄞mus<invalid>ic<invalid>
/// let v = &[0xD834, 0xDD1E, 0x006d, 0x0075,
/// Convert a vector of `char`s to a `String`.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let chars = &['h', 'e', 'l', 'l', 'o'];
/// Return the underlying byte buffer, encoded as UTF-8.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let s = String::from_str("hello");
/// Creates a string buffer by repeating a character `length` times.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let s = String::from_char(5, 'a');
/// Pushes the given string onto this string buffer.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::from_str("foo");
/// Pushes `ch` onto the given string `count` times.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::from_str("foo");
/// Returns the number of bytes that this string buffer can hold without reallocating.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let s = String::with_capacity(10);
///
/// Panics if the new capacity overflows `uint`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::new();
///
/// Panics if the new capacity overflows `uint`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::new();
/// Shrinks the capacity of this string buffer to match its length.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::from_str("foo");
/// Adds the given character to the end of the string.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::from_str("abc");
/// Works with the underlying buffer as a byte slice.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let s = String::from_str("hello");
/// Panics if `new_len` > current length,
/// or if `new_len` is not a character boundary.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::from_str("hello");
/// Removes the last character from the string buffer and returns it.
/// Returns `None` if this string buffer is empty.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::from_str("foo");
/// If `idx` does not lie on a character boundary, then this function will
/// panic.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::from_str("foo");
/// This is unsafe because it does not check
/// to ensure that the resulting string will be valid UTF-8.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = String::from_str("hello");
/// Return the number of bytes in this string.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let a = "foo".to_string();
/// Returns true if the string contains no bytes
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut v = String::new();
/// Truncates the string, returning it to 0 length.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut s = "foo".to_string();
/// as a right child. The time complexity is the same, and re-balancing
/// operations are more frequent but also cheaper.
///
-/// # Example
+/// # Examples
///
/// ```
/// use std::collections::TreeMap;
impl<K: Ord, V> TreeMap<K, V> {
/// Creates an empty `TreeMap`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Gets a lazy iterator over the keys in the map, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Gets a lazy iterator over the values in the map, in ascending order
/// with respect to the corresponding keys.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Gets a lazy iterator over the key-value pairs in the map, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Gets a lazy reverse iterator over the key-value pairs in the map, in descending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Gets a lazy forward iterator over the key-value pairs in the
/// map, with the values being mutable.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Gets a lazy reverse iterator over the key-value pairs in the
/// map, with the values being mutable.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Gets a lazy iterator that consumes the treemap.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Return the number of elements in the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Return true if the map contains no elements.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Clears the map, removing all values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// The key may be any borrowed form of the map's key type, but the ordering
/// on the borrowed form *must* match the ordering on the key type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// The key may be any borrowed form of the map's key type, but the ordering
/// on the borrowed form *must* match the ordering on the key type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// The key may be any borrowed form of the map's key type, but the ordering
/// on the borrowed form *must* match the ordering on the key type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Inserts a key-value pair from the map. If the key already had a value
/// present in the map, that value is returned. Otherwise, `None` is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// The key may be any borrowed form of the map's key type, but the ordering
/// on the borrowed form *must* match the ordering on the key type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// with current key and guides tree navigation. That means `f` should
/// be aware of natural ordering of the tree.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use collections::tree_map::TreeMap;
/// with current key and guides tree navigation. That means `f` should
/// be aware of natural ordering of the tree.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut t = collections::tree_map::TreeMap::new();
/// Returns a lazy iterator to the first key-value pair whose key is not less than `k`
/// If all keys in map are less than `k` an empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// Returns a lazy iterator to the first key-value pair whose key is greater than `k`
/// If all keys in map are less than or equal to `k` an empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// If all keys in map are less than `k` an empty iterator is
/// returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// If all keys in map are less than or equal to `k` an empty iterator
/// is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeMap;
/// only requirement is that the type of the elements contained ascribes to the
/// `Ord` trait.
///
-/// ## Example
+/// ## Examples
///
/// ```{rust}
/// use std::collections::TreeSet;
impl<T: Ord> TreeSet<T> {
/// Creates an empty `TreeSet`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Gets a lazy iterator over the values in the set, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Gets a lazy iterator over the values in the set, in descending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Creates a consuming iterator, that is, one that moves each value out of the
/// set in ascending order. The set cannot be used after calling this.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Gets a lazy iterator pointing to the first value not less than `v` (greater or equal).
/// If all elements in the set are less than `v` empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// If all elements in the set are less than or equal to `v` an
/// empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Visits the values representing the difference, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Visits the values representing the symmetric difference, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Visits the values representing the intersection, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Visits the values representing the union, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Return the number of elements in the set
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Returns true if the set contains no elements
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Clears the set, removing all values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// but the ordering on the borrowed form *must* match the
/// ordering on the value type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Returns `true` if the set has no elements in common with `other`.
/// This is equivalent to checking for an empty intersection.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Returns `true` if the set is a subset of another.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Returns `true` if the set is a superset of another.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// Adds a value to the set. Returns `true` if the value was not already
/// present in the set.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// but the ordering on the borrowed form *must* match the
/// ordering on the value type.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
impl<T: Ord + Clone> BitOr<TreeSet<T>, TreeSet<T>> for TreeSet<T> {
/// Returns the union of `self` and `rhs` as a new `TreeSet<T>`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
impl<T: Ord + Clone> BitAnd<TreeSet<T>, TreeSet<T>> for TreeSet<T> {
/// Returns the intersection of `self` and `rhs` as a new `TreeSet<T>`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
impl<T: Ord + Clone> BitXor<TreeSet<T>, TreeSet<T>> for TreeSet<T> {
/// Returns the symmetric difference of `self` and `rhs` as a new `TreeSet<T>`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
impl<T: Ord + Clone> Sub<TreeSet<T>, TreeSet<T>> for TreeSet<T> {
/// Returns the difference of `self` and `rhs` as a new `TreeSet<T>`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TreeSet;
/// 4 bits. If both numbers are used as keys, a chain of maximum length will be created to
/// differentiate them.
///
-/// # Example
+/// # Examples
///
/// ```
/// use std::collections::TrieMap;
impl<T> TrieMap<T> {
/// Creates an empty `TrieMap`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Visits all key-value pairs in reverse order. Aborts traversal when `f` returns `false`.
/// Returns `true` if `f` returns `true` for all elements.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Gets an iterator over the key-value pairs in the map, ordered by keys.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Gets an iterator over the key-value pairs in the map, with the
/// ability to mutate the values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Return the number of elements in the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Return true if the map contains no elements.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Clears the map, removing all values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Returns a reference to the value corresponding to the key.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Returns true if the map contains a value for the specified key.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Returns a mutable reference to the value corresponding to the key.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Inserts a key-value pair from the map. If the key already had a value
/// present in the map, that value is returned. Otherwise, `None` is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Removes a key from the map, returning the value at the key if the key
/// was previously in the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Gets an iterator pointing to the first key-value pair whose key is not less than `key`.
/// If all keys in the map are less than `key` an empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Gets an iterator pointing to the first key-value pair whose key is greater than `key`.
/// If all keys in the map are not greater than `key` an empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Gets an iterator pointing to the first key-value pair whose key is not less than `key`.
/// If all keys in the map are less than `key` an empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// Gets an iterator pointing to the first key-value pair whose key is greater than `key`.
/// If all keys in the map are not greater than `key` an empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieMap;
/// A set implemented as a radix trie.
///
-/// # Example
+/// # Examples
///
/// ```
/// use std::collections::TrieSet;
impl TrieSet {
/// Creates an empty TrieSet.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Visits all values in reverse order. Aborts traversal when `f` returns `false`.
/// Returns `true` if `f` returns `true` for all elements.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Gets an iterator over the values in the set, in sorted order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Gets an iterator pointing to the first value that is not less than `val`.
/// If all values in the set are less than `val` an empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Gets an iterator pointing to the first value that key is greater than `val`.
/// If all values in the set are less than or equal to `val` an empty iterator is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Visits the values representing the difference, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Visits the values representing the symmetric difference, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Visits the values representing the intersection, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Visits the values representing the union, in ascending order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Return the number of elements in the set
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Returns true if the set contains no elements
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Clears the set, removing all values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Returns `true` if the set contains a value.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Returns `true` if the set has no elements in common with `other`.
/// This is equivalent to checking for an empty intersection.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Returns `true` if the set is a subset of another.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Returns `true` if the set is a superset of another.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Adds a value to the set. Returns `true` if the value was not already
/// present in the set.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
/// Removes a value from the set. Returns `true` if the value was
/// present in the set.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
impl BitOr<TrieSet, TrieSet> for TrieSet {
/// Returns the union of `self` and `rhs` as a new `TrieSet`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
impl BitAnd<TrieSet, TrieSet> for TrieSet {
/// Returns the intersection of `self` and `rhs` as a new `TrieSet`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
impl BitXor<TrieSet, TrieSet> for TrieSet {
/// Returns the symmetric difference of `self` and `rhs` as a new `TrieSet`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
impl Sub<TrieSet, TrieSet> for TrieSet {
/// Returns the difference of `self` and `rhs` as a new `TrieSet`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::TrieSet;
///
/// The vector will not allocate until elements are pushed onto it.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec: Vec<int> = Vec::new();
/// the main `Vec` docs above, 'Capacity and reallocation'.) To create
/// a vector of a given length, use `Vec::from_elem` or `Vec::from_fn`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec: Vec<int> = Vec::with_capacity(10);
/// Creates a `Vec` of size `length` and initializes the elements to the
/// value returned by the closure `op`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let vec = Vec::from_fn(3, |idx| idx * 2);
///
/// This is highly unsafe, due to the number of invariants that aren't checked.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::ptr;
/// satisfy `f` and all elements of `B` do not. The order of elements is
/// preserved.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let vec = vec![1i, 2i, 3i, 4i];
///
/// Creates a `Vec` with `length` copies of `value`.
///
- /// # Example
+ /// # Examples
+ ///
/// ```
/// let vec = Vec::from_elem(3, "hi");
/// println!("{}", vec); // prints [hi, hi, hi]
/// Iterates over the slice `other`, clones each element, and then appends
/// it to this `Vec`. The `other` vector is traversed in-order.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec = vec![1i];
///
/// Adds `n` copies of `value` to the `Vec`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec = vec!["hello"];
/// `(a, b)`, where all elements of `a` satisfy `f` and all elements of `b`
/// do not. The order of elements is preserved.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let vec = vec![1i, 2, 3, 4];
/// Returns the number of elements the vector can hold without
/// reallocating.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let vec: Vec<int> = Vec::with_capacity(10);
///
/// Panics if the new capacity overflows `uint`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec: Vec<int> = vec![1];
///
/// Panics if the new capacity overflows `uint`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec: Vec<int> = vec![1];
/// down as close as possible to the length but the allocator may still
/// inform the vector that there is space for a few more elements.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec: Vec<int> = Vec::with_capacity(10);
/// If `len` is greater than the vector's current length, this has no
/// effect.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec = vec![1i, 2, 3, 4];
/// Returns a mutable slice of the elements of `self`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// fn foo(slice: &mut [int]) {}
/// value out of the vector (from start to end). The vector cannot
/// be used after calling this.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let v = vec!["a".to_string(), "b".to_string()];
/// modifying its buffers, so it is up to the caller to ensure that the
/// vector is actually the specified size.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut v = vec![1u, 2, 3, 4];
///
/// Returns `None` if `index` is out of bounds.
///
- /// # Example
+ /// # Examples
+ ///
/// ```
/// let mut v = vec!["foo", "bar", "baz", "qux"];
///
/// Panics if `index` is not between `0` and the vector's length (both
/// bounds inclusive).
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec = vec![1i, 2, 3];
/// shifting all elements after position `index` one position to the left.
/// Returns `None` if `i` is out of bounds.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut v = vec![1i, 2, 3];
/// In other words, remove all elements `e` such that `f(&e)` returns false.
/// This method operates in place and preserves the order of the retained elements.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec = vec![1i, 2, 3, 4];
/// The vector is grown by `n` elements. The i-th new element are initialized to the value
/// returned by `f(i)` where `i` is in the range [0, n).
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec = vec![0u, 1];
///
/// Panics if the number of elements in the vector overflows a `uint`.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let mut vec = vec!(1i, 2);
/// Removes the last element from a vector and returns it, or `None` if
/// it is empty.
///
- /// # Example
+ /// # Examples
///
/// ```rust
/// let mut vec = vec![1i, 2, 3];
/// Clears the vector, removing all values.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut v = vec![1i, 2, 3];
/// Return the number of elements in the vector
///
- /// # Example
+ /// # Examples
///
/// ```
/// let a = vec![1i, 2, 3];
/// Returns true if the vector contains no elements
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut v = Vec::new();
///
/// If the vector is sorted, this removes all duplicates.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let mut vec = vec![1i, 2, 2, 3, 2];
impl<T> AsSlice<T> for Vec<T> {
/// Returns a slice into `self`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// fn foo(slice: &[int]) {}
/// Panics if `T` and `U` have differing sizes or are not zero-sized and
/// have differing minimal alignments.
///
- /// # Example
+ /// # Examples
///
/// ```
/// let v = vec![0u, 1, 2];
/// A map optimized for small integer keys.
///
-/// # Example
+/// # Examples
///
/// ```
/// use std::collections::VecMap;
impl<V> VecMap<V> {
/// Creates an empty `VecMap`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Creates an empty `VecMap` with space for at least `capacity`
/// elements before resizing.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Returns the number of elements the `VecMap` can hold without
/// reallocating.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Returns an iterator visiting all key-value pairs in ascending order by the keys.
/// The iterator's element type is `(uint, &'r V)`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// with mutable references to the values.
/// The iterator's element type is `(uint, &'r mut V)`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// the keys, emptying (but not consuming) the original `VecMap`.
/// The iterator's element type is `(uint, &'r V)`.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Return the number of elements in the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Return true if the map contains no elements.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Clears the map, removing all key-value pairs.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Returns a reference to the value corresponding to the key.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Returns true if the map contains a value for the specified key.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Returns a mutable reference to the value corresponding to the key.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Inserts a key-value pair from the map. If the key already had a value
/// present in the map, that value is returned. Otherwise, `None` is returned.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Removes a key from the map, returning the value at the key if the key
/// was previously in the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Otherwise, sets the value to `newval`.
/// Returns `true` if the key did not already exist in the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;
/// Otherwise, sets the value to `newval`.
/// Returns `true` if the key did not already exist in the map.
///
- /// # Example
+ /// # Examples
///
/// ```
/// use std::collections::VecMap;