list_builder

Crates.iolist_builder
lib.rslist_builder
version0.0.2
sourcesrc
created_at2015-03-21 04:29:44.527636
updated_at2015-12-11 23:54:10.497015
descriptionPython-like list comprehensions in Rust
homepagehttps://github.com/natemara/rust-list-builder
repositoryhttps://github.com/natemara/rust-list-builder
max_upload_size
id1628
size5,807
Lily Mara (lily-mara)

documentation

http://natemara.github.io/rust-list-builder/list_builder/

README

Rust List Builder

List/set/generator comprehensions are one of the best features of Python and Haskell. They make creating complex iterables simpler and more intuitive. This crate attempts to add similar functionality to the Rust language.

This crate provides the gen! macro. Its syntax is similar to Python list comprehensions:

#[macro_use(gen)]
#[no_link]
extern crate list_builder;

fn main() {
	let x: Vec<i32> = gen![i*1000 => i in [1, 2, 3, 4, 5, 6]];
}

You can use conditionals just like in Python:

let x: Vec<i32> = gen![i*1000 => i in [1, 2, 3, 4, 5, 6], i % 2 == 0];
assert_eq!(x, vec![2000, 4000, 6000]);
Commit count: 12

cargo fmt