# [−][src]Macro smallvec::smallvec

    macro_rules! smallvec {
        (@one $x:expr) => { ... };
        ($elem:expr; $n:expr) => { ... };
        ($($x:expr),*$(,)*) => { ... };
    }

Creates a [`SmallVec`] containing the arguments.

`smallvec!` allows `SmallVec`s to be defined with the same syntax as array expressions. There are two forms of this macro:

- Create a [`SmallVec`] containing a given list of elements:

    let v: SmallVec<[_; 128]> = smallvec![1, 2, 3];
    assert_eq!(v[0], 1);
    assert_eq!(v[1], 2);
    assert_eq!(v[2], 3);

- Create a [`SmallVec`] from a given element and size:

    let v: SmallVec<[_; 0x8000]> = smallvec![1; 3];
    assert_eq!(v, SmallVec::from_buf([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, `smallvec![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.

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## 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` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)