Skip to content

Commit b9de175

Browse files
committed
More docs.
1 parent a429a37 commit b9de175

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/lib.rs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ The following optional features are available:
4343
4444
* `tuples-16`: implement scanning for tuples of up to 16 elements. The default is up to 4 elements.
4545
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+
4654
## Quick Examples
4755
4856
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() {
128136
}
129137
```
130138
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
132159
133160
A scanning pattern is made up of one or more pattern terms, separated by commas. The following terms are supported:
134161
@@ -162,14 +189,6 @@ A scanning pattern is made up of one or more pattern terms, separated by commas.
162189
163190
*E.g.* `[ let nums: i32 ],+`, `[ "pretty" ]*, "please"`.
164191
165-
## Things What Need Mentioning
166-
167-
* *Rule* syntax.
168-
* Scanners and things like `Word` being abstract.
169-
* Cursor(s).
170-
* More examples.
171-
* `#![recursion_limit]`
172-
173192
*/
174193
#![forbid(missing_docs)]
175194
#![recursion_limit="128"]

0 commit comments

Comments
 (0)