fixed documentation on crates.io
This commit is contained in:
parent
154840f9f8
commit
2120f8c481
2 changed files with 19 additions and 19 deletions
30
README.md
30
README.md
|
@ -13,32 +13,32 @@ The only special characters in templates are curly brackets ('{}'). These act as
|
|||
## Examples:
|
||||
|
||||
```rust
|
||||
# #[macro_use] extern crate eyes;
|
||||
# fn main() {
|
||||
let input = "#lol @ 338,7643: 20.2x24.5";
|
||||
let template = "#{} @ {},{}: {}x{}";
|
||||
#[macro_use] extern crate eyes; // not normally necessary
|
||||
fn main() {
|
||||
let input = "#lol @ 338,7643: 20.2x24.5";
|
||||
let template = "#{} @ {},{}: {}x{}";
|
||||
|
||||
let (id, x, y, w, h) = eyes::parse!(input, template, String, isize, isize, f64, f64);
|
||||
let (id, x, y, w, h) = eyes::parse!(input, template, String, isize, isize, f64, f64);
|
||||
|
||||
assert_eq!((id.as_str(), x, y, w, h), ("lol", 338, 7643, 20.2, 24.5));
|
||||
# }
|
||||
assert_eq!((id.as_str(), x, y, w, h), ("lol", 338, 7643, 20.2, 24.5));
|
||||
}
|
||||
```
|
||||
|
||||
**eyes** will try to expand capture groups, so that the following example also works as expected:
|
||||
|
||||
```rust
|
||||
# #[macro_use] extern crate eyes;
|
||||
# fn main() {
|
||||
let input = "turn off 660,55 through 986,197";
|
||||
let template = "{} {},{} through {},{}";
|
||||
#[macro_use] extern crate eyes; // not normally necessary
|
||||
fn main() {
|
||||
let input = "turn off 660,55 through 986,197";
|
||||
let template = "{} {},{} through {},{}";
|
||||
|
||||
let (op, x1, y1, x2, y2) = eyes::parse!(input, template, String, usize, usize, usize, usize);
|
||||
let (op, x1, y1, x2, y2) = eyes::parse!(input, template, String, usize, usize, usize, usize);
|
||||
|
||||
assert_eq!(
|
||||
assert_eq!(
|
||||
(op.as_str(), x1, y1, x2, y2),
|
||||
("turn off", 660, 55, 986, 197)
|
||||
);
|
||||
# }
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
Notice that "turn off" is captured correctly, even though it contains a space.
|
||||
|
|
|
@ -15,7 +15,7 @@ impl<'a> Captures<'a> {
|
|||
///
|
||||
/// The input and template strings must live as long as the list of captures itself, as the captures list borrows from them.
|
||||
///
|
||||
/// # Examples
|
||||
/// ## Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
/// ```
|
||||
|
@ -124,7 +124,7 @@ macro_rules! try_parse {
|
|||
/// - The template does not match the input.
|
||||
/// - The capture could not be converted to the specified type.
|
||||
///
|
||||
/// # Examples
|
||||
/// ## Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
/// ```
|
||||
|
|
Loading…
Reference in a new issue