You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-1Lines changed: 43 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,51 @@ Partially covered libraries:
22
22
23
23
* Does not support while loop
24
24
25
+
(No plans to support this, [using let expression](#let-expression) is already powerful enough)
25
26
26
-
# Collection Comprehensions
27
+
# Overview
28
+
The syntax is derived from [python comprehensions](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions), but provides more powerful features, closer to the usage of Rust
29
+
30
+
This library provides comprehension macros for all collection types in the Rust standard library
31
+
32
+
( Vec and std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque})
33
+
34
+
And provides iterator comprehension macros based on references
*It is not required to break lines, it is just for readability*
63
+
64
+
*`left/right_mapping/key/value` is an expression that produces a value, which can be a [simple expression](#simple-example), or a [block expression](#execute-code-in-block-before-returning)
65
+
*`if conditions` is an expression that produces a bool
66
+
*`for pattern in iterable` where `pattern` is a [pattern](#use-pattern-matching), and `iterable` is an iterable object
67
+
*`let expression` is a let expression, which can [bind variables](#use-let-expression-to-bind-variables) or [execute arbitrary code](#use-let-_--or-let---to-execute-code)
68
+
69
+
# Collection Comprehensions
28
70
You can completely treat collection comprehension macros as sugar for `for loop`
29
71
(In fact, these macros are implemented using `for loop`)
Copy file name to clipboardExpand all lines: src/lib.rs
+43Lines changed: 43 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,49 @@ Partially covered libraries:
23
23
24
24
* Does not support while loop
25
25
26
+
(No plans to support this, [using let expression](#let-expression) is already powerful enough)
27
+
28
+
# Overview
29
+
The syntax is derived from [python comprehensions](https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions), but provides more powerful features, closer to the usage of Rust
30
+
31
+
This library provides comprehension macros for all collection types in the Rust standard library
32
+
33
+
( Vec and std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque})
34
+
35
+
And provides iterator comprehension macros based on references
*It is not required to break lines, it is just for readability*
64
+
65
+
* `left/right_mapping/key/value` is an expression that produces a value, which can be a [simple expression](#simple-example), or a [block expression](#execute-code-in-block-before-returning)
66
+
* `if conditions` is an expression that produces a bool
67
+
* `for pattern in iterable` where `pattern` is a [pattern](#use-pattern-matching), and `iterable` is an iterable object
68
+
* `let expression` is a let expression, which can [bind variables](#use-let-expression-to-bind-variables) or [execute arbitrary code](#use-let-_--or-let---to-execute-code)
0 commit comments