We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 941d6aa commit 19048d5Copy full SHA for 19048d5
README.md
@@ -6,3 +6,21 @@ rust-smallvec
6
[Release notes](https://github.com/servo/rust-smallvec/releases)
7
8
"Small vector" optimization for Rust: store up to a small number of items on the stack
9
+
10
+## Example
11
12
+```rust
13
+use smallvec::{SmallVec, smallvec};
14
15
+// This SmallVec can hold up to 4 items on the stack:
16
+let mut v: SmallVec<[i32; 4]> = smallvec![1, 2, 3, 4];
17
18
+// It will automatically move its contents to the heap if
19
+// contains more than four items:
20
+v.push(5);
21
22
+// SmallVec points to a slice, so you can use normal slice
23
+// indexing and other methods to access its contents:
24
+v[0] = v[1] + v[2];
25
+v.sort();
26
+```
0 commit comments