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: src/lib.rs
+28-9Lines changed: 28 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,14 @@ The following optional features are available:
43
43
44
44
* `tuples-16`: implement scanning for tuples of up to 16 elements. The default is up to 4 elements.
45
45
46
+
## Important Notes
47
+
48
+
* There are no default scanners for `&str` or `String`; if you want a string, you should pick an appropriate abstract scanner from the [`scanner`](scanner/index.html) module.
49
+
50
+
* The macros in this crate are extremely complex. Moderately complex usage can exhaust the standard macro recursion limit. If this happens, you can raise the limit (from its default of 64) by adding the following attribute to your crate's root module:
51
+
52
+
`#![recursion_limit="128"]`
53
+
46
54
## Quick Examples
47
55
48
56
Here is a simple CLI program that asks the user their name and age. You can run this using `cargo run --example ask_age`.
@@ -128,7 +136,26 @@ fn main() {
128
136
}
129
137
```
130
138
131
-
## Pattern Syntax
139
+
## Rule Syntax
140
+
141
+
Scanning rules are written as one or more arms like so:
142
+
143
+
```ignore
144
+
scan! { input_expression;
145
+
( pattern ) => body,
146
+
( pattern ) => body,
147
+
...
148
+
( pattern ) => body,
149
+
}
150
+
```
151
+
152
+
Note that the trailing comma on the last rule is optional.
153
+
154
+
Rules are checked top-to-bottom, stopping at the first that matches.
155
+
156
+
Patterns (explained under ["Pattern Syntax"](#pattern-syntax)) must be enclosed in parentheses. If a pattern matches the provided input, the corresponding body is evaluated.
157
+
158
+
### Pattern Syntax
132
159
133
160
A scanning pattern is made up of one or more pattern terms, separated by commas. The following terms are supported:
134
161
@@ -162,14 +189,6 @@ A scanning pattern is made up of one or more pattern terms, separated by commas.
162
189
163
190
*E.g.* `[ let nums: i32 ],+`, `[ "pretty" ]*, "please"`.
0 commit comments