From 2120f8c481869a61a5be7edfe067aa707b19a544 Mon Sep 17 00:00:00 2001 From: vodofrede Date: Tue, 15 Nov 2022 13:15:39 +0100 Subject: [PATCH] fixed documentation on crates.io --- README.md | 34 +++++++++++++++++----------------- src/lib.rs | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 7b0513e..2d6f109 100644 --- a/README.md +++ b/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!( - (op.as_str(), x1, y1, x2, y2), - ("turn off", 660, 55, 986, 197) -); -# } + 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. diff --git a/src/lib.rs b/src/lib.rs index 9763de4..e1c3e78 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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: /// ```