From: Greg Burri Date: Mon, 5 Jul 2021 08:55:51 +0000 (+0200) Subject: Add doc to a function X-Git-Url: http://git.euphorik.ch/index.cgi?a=commitdiff_plain;h=6d4fd4f074854c8fac1f9a1af606dae9a3a33977;p=rust_in_action.git Add doc to a function --- diff --git a/ch2-str-simple-pattern/src/main.rs b/ch2-str-simple-pattern/src/main.rs index b09af0a..51fccf0 100644 --- a/ch2-str-simple-pattern/src/main.rs +++ b/ch2-str-simple-pattern/src/main.rs @@ -43,13 +43,26 @@ fn main() { } } +/** +Process text lines from the given reader and try to find the given pattern. +*(This is just an example of inline documentation)* + +# Some random XML code + +``` xml + + + + +``` +*/ fn process_lines(reader: T, pattern_re: Regex) { for (i, line_result) in reader.lines().enumerate() { match line_result { Ok(line) => { let contains_substring = pattern_re.find(&line); match contains_substring { - Some(_) => println!("Found \"{}\" at line number {}", pattern_re, i + 1), + Some(_) => println!("Found \"{}\" in line number {}", pattern_re, i + 1), None => (), } },