     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83

    // Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
    // file at the top-level directory of this distribution and at
    // http://rust-lang.org/COPYRIGHT.
    //
    // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
    // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
    // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
    // option. This file may not be copied, modified, or distributed
    // except according to those terms.

    /// Creates a `Vec` containing the arguments.
    ///
    /// `vec!` allows `Vec`s to be defined with the same syntax as array expressions.
    /// There are two forms of this macro:
    ///
    /// - Create a `Vec` containing a given list of elements:
    ///
    /// ```
    /// let v = vec![1, 2, 3];
    /// assert_eq!(v[0], 1);
    /// assert_eq!(v[1], 2);
    /// assert_eq!(v[2], 3);
    /// ```
    ///
    /// - Create a `Vec` from a given element and size:
    ///
    /// ```
    /// let v = vec![1; 3];
    /// assert_eq!(v, [1, 1, 1]);
    /// ```
    ///
    /// Note that unlike array expressions this syntax supports all elements
    /// which implement `Clone` and the number of elements doesn't have to be
    /// a constant.
    ///
    /// This will use `clone()` to duplicate an expression, so one should be careful
    /// using this with types having a nonstandard `Clone` implementation. For
    /// example, `vec![Rc::new(1); 5]` will create a vector of five references
    /// to the same boxed integer value, not five references pointing to independently
    /// boxed integers.
    #[cfg(not(test))]
    #[macro_export]
    #[stable(feature = "rust1", since = "1.0.0")]
    macro_rules! vec {
        ($elem:expr; $n:expr) => (
            $crate::vec::from_elem($elem, $n)
        );
        ($($x:expr),*) => (
            <[_]>::into_vec($crate::boxed::Box::new([$($x),*]))
        );
        ($($x:expr,)*) => (vec![$($x),*])
    }

    // HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is
    // required for this macro definition, is not available. Instead use the
    // `slice::into_vec`  function which is only available with cfg(test)
    // NB see the slice::hack module in slice.rs for more information
    #[cfg(test)]
    macro_rules! vec {
        ($elem:expr; $n:expr) => (
            $crate::vec::from_elem($elem, $n)
        );
        ($($x:expr),*) => (
            $crate::slice::into_vec($crate::boxed::Box::new([$($x),*]))
        );
        ($($x:expr,)*) => (vec![$($x),*])
    }

    /// Use the syntax described in `std::fmt` to create a value of type `String`.
    /// See `std::fmt` for more information.
    ///
    /// # Examples
    ///
    /// ```
    /// format!("test");
    /// format!("hello {}", "world!");
    /// format!("x = {}, y = {y}", 10, y = 30);
    /// ```
    #[macro_export]
    #[stable(feature = "rust1", since = "1.0.0")]
    macro_rules! format {
        ($($arg:tt)*) => ($crate::fmt::format(format_args!($($arg)*)))
    }

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize`)