Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmg-duarte/exhaustive-rs
Python-like comprehensions in Rust!
https://github.com/jmg-duarte/exhaustive-rs
Last synced: about 2 hours ago
JSON representation
Python-like comprehensions in Rust!
- Host: GitHub
- URL: https://github.com/jmg-duarte/exhaustive-rs
- Owner: jmg-duarte
- Created: 2020-12-15T21:45:01.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-06T11:49:23.000Z (about 4 years ago)
- Last Synced: 2024-11-25T22:27:16.997Z (2 months ago)
- Language: Rust
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `exhaustive`
> exhaustive /ɪɡˈzɔːstɪv,ɛɡˈzɔːstɪv/ - **including or considering all elements or aspects; fully comprehensive.**
This crate was born from issue [#23](https://github.com/dtolnay/proc-macro-workshop/issues/23) in `dtolnay/proc_macro_workshop`.
> I'd like to see a basic implementation of a macro for Python-style list and map comprehensions, and decide whether it would be a better teaching example for function-like proc macros than the current `seq!` project.
>
> Something like:
> ```rust
> let squares_map = c![n => n*n for n in 0..100 if n % 5 != 0];
> ```## Previous Work
There are some crates which implement this functionality or really similar,
however, most of the crates are implemented using `macro_rules!`.**Captain Obvious**: Which is *not* a procedural macro and thus not adequate as a learning example of such.
The existing crates are:
- [`cute`](https://crates.io/crates/cute) - *Macro for Python-esque list comprehensions in Rust.*
- [`mapcomp`](https://crates.io/crates/mapcomp) - *Python-like list comprehension via macros for some standard containers.*
- [`iter-comprehensions`](https://crates.io/crates/iter-comprehensions) - *A library for iterator comprehensions.*
- [`comprehension`](https://crates.io/crates/comprehension) - *Iterator comprehension in Rust.*The last one, `comprehension`, is the only one implemented using function-like procedural macros,
however the syntax is based on Haskell, not Python.