Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeertmans/comptools
Create iterators using Python's list comprehesion style.
https://github.com/jeertmans/comptools
Last synced: about 5 hours ago
JSON representation
Create iterators using Python's list comprehesion style.
- Host: GitHub
- URL: https://github.com/jeertmans/comptools
- Owner: jeertmans
- License: mit
- Created: 2022-02-24T15:29:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-02-24T16:07:34.000Z (over 2 years ago)
- Last Synced: 2024-09-15T15:53:13.744Z (18 days ago)
- Language: Rust
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# CompTools
[![Crates.io](https://img.shields.io/crates/v/comptools)](https://crates.io/crates/comptools)
[![docs.rs](https://img.shields.io/docsrs/comptools)](https://docs.rs/comptools)## Create iterators using Python's list comprehesion style.
Macros for Python-like list comprehension creation of iterators.
Another Crate that tries to bring the simplicty of Python's syntax to Rust iterators.
The main macro is `iter`, and other macros are extensions of the latter.
# Examples
Below, small examples of how the macros work:
```rust
use comptools::*;let vec: Vec = vect![x*x; for x in 0..=10; if x % 2 == 0];
assert_eq!(vec, vec![0, 4, 16, 36, 64, 100]);let sum: u64 = sum![x*x; for x in 1..; while x*x*x < 1234];
assert_eq!(sum, 385);
```## Contributing
Contributions are more than welcome!