Crates.io | svec |
lib.rs | svec |
version | 0.1.0 |
source | src |
created_at | 2019-11-08 19:07:48.385306 |
updated_at | 2019-11-08 19:07:48.385306 |
description | A utility for Dart-style list in Rust |
homepage | https://www.github.com/calebwin/svec |
repository | https://www.github.com/calebwin/svec |
max_upload_size | |
id | 179455 |
size | 3,757 |
svec
Svec lets you create beautiful Dart-like lists in Rust that are both readable and concise.
If you're making a list of things in Rust, you're probably using vec
.
// a list
let row = vec![
Elem::IconButton("hamburger"),
Elem::Space,
Elem::IconButton("info"),
Elem::IconButton("profile")
];
svec
lets you do all the things you can do with vec
, but it also adds "collection if" and "collection for".
// a list with svec
let row = svec![
Elem::IconButton("hamburger"),
Elem::Space,
Elem::IconButton("info"),
Elem::IconButton("profile"),
if isLiteVersion { Elem::IconButton("store") }
];
Here's a "collection for".
// a list with vec + svec
let row = vec![
Elem::IconButton("hamburger"),
Elem::Space,
Elem::IconButton("info"),
Elem::IconButton("profile"),
Elem::MenuBar(svec![
for friend in friends.take(3) { Elem::MenuItem(friend) },
Elem::MenuItem("All friends"),
Elem::MenuItem("All people"),
])
];
Using svec
in your project is super easy.
svec = 0.1.0
to your Cargo.toml
.use svec::*
.