From 16ec3a96e4b43116518339dde6e43fe961a49f1d Mon Sep 17 00:00:00 2001 From: Zykino <3809938+Zykino@users.noreply.github.com> Date: Thu, 30 Jul 2026 00:25:09 +0200 Subject: [PATCH] cargo fmt + fix clippy warnings --- src/main.rs | 24 +- src/render.rs | 62 ++- src/scan.rs | 1091 +++++++++++++++++++++++++++++-------------------- 3 files changed, 694 insertions(+), 483 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5344371..2cb3be0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,14 @@ use std::fs::canonicalize; use std::path::PathBuf; -use clap::{Parser, ArgAction}; use crate::entries::Entry; use crate::render::render_entries; -use crate::scan::{Stats, scan_dir, scan_todo_file, scan_readme_file, Exclude}; +use crate::scan::{Exclude, Stats, scan_dir, scan_readme_file, scan_todo_file}; +use clap::{ArgAction, Parser}; -pub mod scan; -pub mod render; pub mod entries; +pub mod render; +pub mod scan; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] @@ -66,10 +66,10 @@ fn main() { let mut path = root_dir.clone(); path.push(exclude); - if path.exists() { - if let Ok(realpath) = canonicalize(path) { - excludes.push(Exclude::Path(realpath)); - } + if path.exists() + && let Ok(realpath) = canonicalize(path) + { + excludes.push(Exclude::Path(realpath)); } } @@ -100,9 +100,9 @@ fn main() { if args.verbose > 0 { eprint!("\n\n"); stats.print(); - eprintln!("Paths ({}): {:?}", &paths.len(), &paths); - eprintln!("Excludes ({}): {:?}", &excludes.len(), &excludes); - eprintln!("todo.md: {:?}", &todos_path); - eprintln!("readme.md: {:?}", &readme_path); + eprintln!("Paths ({}): {:?}", paths.len(), paths); + eprintln!("Excludes ({}): {:?}", excludes.len(), excludes); + eprintln!("todo.md: {:?}", todos_path); + eprintln!("readme.md: {:?}", readme_path); } } diff --git a/src/render.rs b/src/render.rs index 5e89c6b..8ab3f24 100644 --- a/src/render.rs +++ b/src/render.rs @@ -1,7 +1,7 @@ -use std::io::Write; +use std::cmp::Ordering::{Equal, Greater, Less}; use std::collections::HashMap; +use std::io::Write; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; -use std::cmp::Ordering::{Less, Equal, Greater}; use crate::entries::{Entry, EntryData}; @@ -10,11 +10,20 @@ impl Entry { let mut stdout = StandardStream::stdout(ColorChoice::Auto); write_ansi(&mut stdout, Color::Ansi256(243), "- [ ] ", false); - let location = format!("{}:{}", self.location.file.to_string_lossy(), self.location.line); + let location = format!( + "{}:{}", + self.location.file.to_string_lossy(), + self.location.line + ); - if ! self.text.is_empty() { + if !self.text.is_empty() { write_ansi(&mut stdout, Color::Blue, self.text.as_str(), true); - write_ansi(&mut stdout, Color::Ansi256(243), format!(" ({})", location).as_str(), false); + write_ansi( + &mut stdout, + Color::Ansi256(243), + format!(" ({})", location).as_str(), + false, + ); } else { write_ansi(&mut stdout, Color::Cyan, location.as_str(), true); } @@ -23,13 +32,10 @@ impl Entry { } } - pub fn write_ansi(stdout: &mut StandardStream, color: Color, text: &str, bold: bool) { - stdout.set_color( - ColorSpec::new() - .set_fg(Some(color)) - .set_bold(bold) - ).unwrap(); + stdout + .set_color(ColorSpec::new().set_fg(Some(color)).set_bold(bold)) + .unwrap(); write!(stdout, "{text}").unwrap(); @@ -46,21 +52,19 @@ pub fn render_entries(entries: Vec) { for entry in entries { match entry.data { EntryData::Priority(priority) => { - if ! priority_entries.contains_key(&priority) { - priority_entries.insert(priority, vec![]); - } + priority_entries.entry(priority).or_default(); let vec = priority_entries.get_mut(&priority).unwrap(); vec.push(entry); - }, + } EntryData::Category(ref category) => { - if ! category_entries.contains_key(category) { + if !category_entries.contains_key(category) { category_entries.insert(category.clone(), vec![]); } let vec = category_entries.get_mut(category).unwrap(); vec.push(entry); - }, + } EntryData::Generic => { generic_entries.push(entry); } @@ -81,15 +85,24 @@ pub fn render_entries(entries: Vec) { // todo0 -> 0 // todo00 -> -1 // Therefore: 'todo0' + priority.abs() * '0' - str.push_str(String::from_utf8(vec![b'0'; priority.unsigned_abs()]).unwrap().as_str()); + str.push_str( + String::from_utf8(vec![b'0'; priority.unsigned_abs()]) + .unwrap() + .as_str(), + ); str - }, + } Equal => "todo0".to_string(), Greater => format!("todo{}", priority), }; - write_ansi(&mut stdout, Color::Red, format!("## {}", &priority_notation).as_str(), true); + write_ansi( + &mut stdout, + Color::Red, + format!("## {}", priority_notation).as_str(), + true, + ); writeln!(stdout).unwrap(); for item in priority_entries.get(priority).unwrap() { @@ -103,7 +116,12 @@ pub fn render_entries(entries: Vec) { category_keys.sort_by(|a, b| a.partial_cmp(b).unwrap()); for category in category_keys { - write_ansi(&mut stdout, Color::Green, format!("## {}", &category).as_str(), true); + write_ansi( + &mut stdout, + Color::Green, + format!("## {}", category).as_str(), + true, + ); writeln!(stdout).unwrap(); for item in category_entries.get(category).unwrap() { @@ -113,7 +131,7 @@ pub fn render_entries(entries: Vec) { println!(); } - if generic_entries.len() > 0 { + if !generic_entries.is_empty() { write_ansi(&mut stdout, Color::White, "## Other", true); writeln!(stdout).unwrap(); diff --git a/src/scan.rs b/src/scan.rs index 4dda5f3..716c552 100644 --- a/src/scan.rs +++ b/src/scan.rs @@ -1,7 +1,7 @@ -use std::io; +use glob::Pattern; use std::fs::{self, canonicalize}; +use std::io; use std::path::{Path, PathBuf}; -use glob::{Pattern}; const PRIORITY_CHARS: [char; 10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; @@ -45,7 +45,7 @@ impl Stats { self.visited_file_count += 1; if self.verbosity >= 3 { - eprintln!("[INFO] Visited file: {}", &file); + eprintln!("[INFO] Visited file: {}", file); } if self.verbosity >= 2 { @@ -57,7 +57,7 @@ impl Stats { self.visited_folder_count += 1; if self.verbosity >= 3 { - eprintln!("[INFO] Visited folder: {}", &folder); + eprintln!("[INFO] Visited folder: {}", folder); } if self.verbosity >= 2 { @@ -106,7 +106,9 @@ fn parse_priority(word: &str) -> Option { /// Remove closing tags, comments, and whitespace fn clean_line<'a>(line: &'a str, delimiter_word: &str) -> &'a str { - line.split_once(delimiter_word).unwrap().1 + line.split_once(delimiter_word) + .unwrap() + .1 .trim() .trim_end_matches("*/") .trim_end_matches("-->") @@ -119,7 +121,7 @@ pub fn add_excludes_from_gitignore(base_dir: &PathBuf, excludes: &mut Vec) { // Handles: `todo`, `TODO`, `todo:`, `TODO:` // Also trims `"` and `'` to handle cases like `foo="bar todo"` - if word.to_lowercase().trim_end_matches('"').trim_end_matches('\'') == "todo" { + if word + .to_lowercase() + .trim_end_matches('"') + .trim_end_matches('\'') + == "todo" + { entries.push(Entry { text: text.to_string(), location: Location { @@ -214,17 +221,17 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec) { continue; } - if word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) { - if let Some(priority) = parse_priority(word) { - entries.push(Entry { - text: text.to_string(), - location: Location { - file: filename.clone(), - line: line_num + 1, - }, - data: EntryData::Priority(priority), - }); - } + if word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) + && let Some(priority) = parse_priority(word) + { + entries.push(Entry { + text: text.to_string(), + location: Location { + file: filename.clone(), + line: line_num + 1, + }, + data: EntryData::Priority(priority), + }); continue; } @@ -240,7 +247,12 @@ pub fn scan_file(path: &Path, entries: &mut Vec) -> io::Result<()> { Ok(()) } -pub fn scan_dir(dir: &Path, entries: &mut Vec, excludes: &mut Vec, stats: &mut Stats) -> io::Result<()> { +pub fn scan_dir( + dir: &Path, + entries: &mut Vec, + excludes: &mut Vec, + stats: &mut Stats, +) -> io::Result<()> { let mut gitignore = dir.to_path_buf().clone(); gitignore.push(".gitignore"); @@ -264,7 +276,14 @@ pub fn scan_dir(dir: &Path, entries: &mut Vec, excludes: &mut Vec) -> io::Result<()> { // If we are in an *unindented* code block, we ignore lines // starting with # - they cannot be headings. Indented // code blocks are irrelevant. - in_code_block = ! in_code_block; + in_code_block = !in_code_block; continue; } // We need the line to start with # followed by spaces. So we cannot check just for '#' // There's also no real need for any complex logic iterating over the line's characters, // we can just check reasonable heading hierarchy like this. Anything else is unlikely. - if ! in_code_block && (false - || line.starts_with("# ") - || line.starts_with("## ") - || line.starts_with("### ") - || line.starts_with("#### ") - || line.starts_with("##### ") - ) { + if !in_code_block + && (false + || line.starts_with("# ") + || line.starts_with("## ") + || line.starts_with("### ") + || line.starts_with("#### ") + || line.starts_with("##### ")) + { current_category = Some(line.split_once("# ").unwrap().1); continue; } - if ! line.trim_start().starts_with('-') { + if !line.trim_start().starts_with('-') { continue; } for word in line.split_whitespace() { - if word.to_lowercase().trim_end_matches(':').starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) { + if word + .to_lowercase() + .trim_end_matches(':') + .starts_with("todo") + && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) + { if let Some(priority) = parse_priority(word.trim_end_matches(':')) { entries.push(Entry { text: clean_line(line, word).to_string(), @@ -339,7 +364,11 @@ pub fn scan_todo_file(path: &Path, entries: &mut Vec) -> io::Result<()> { } } - let text = line.trim_start().trim_start_matches("- [ ] ").trim_start_matches("- ").to_string(); + let text = line + .trim_start() + .trim_start_matches("- [ ] ") + .trim_start_matches("- ") + .to_string(); if let Some(category) = current_category { entries.push(Entry { @@ -381,38 +410,48 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec) -> io::Result<()> // If we are in an *unindented* code block, we ignore lines // starting with # - they cannot be headings. Indented // code blocks are irrelevant. - in_code_block = ! in_code_block; + in_code_block = !in_code_block; continue; } // We need the line to start with # followed by spaces. So we cannot check just for '#' // There's also no real need for any complex logic iterating over the line's characters, // we can just check reasonable heading hierarchy like this. Anything else is unlikely. - if ! in_code_block && (false - || line.starts_with("# ") - || line.starts_with("## ") - || line.starts_with("### ") - || line.starts_with("#### ") - || line.starts_with("##### ") - ) { + if !in_code_block + && (false + || line.starts_with("# ") + || line.starts_with("## ") + || line.starts_with("### ") + || line.starts_with("#### ") + || line.starts_with("##### ")) + { let section = line.split_once("# ").unwrap().1; - let cleaned_section = section.to_lowercase().trim_end_matches(':').trim().to_string(); + let cleaned_section = section + .to_lowercase() + .trim_end_matches(':') + .trim() + .to_string(); in_todo_section = cleaned_section == "todo" || cleaned_section == "todos"; continue; } - if ! in_todo_section { + if !in_todo_section { continue; } - if ! line.trim_start().starts_with('-') { + if !line.trim_start().starts_with('-') { continue; } for word in line.split_whitespace() { - if word.to_lowercase().trim_end_matches(':').starts_with("todo") && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) { + if word + .to_lowercase() + .trim_end_matches(':') + .starts_with("todo") + && word.chars().any(|ch| PRIORITY_CHARS.contains(&ch)) + { if let Some(priority) = parse_priority(word.trim_end_matches(':')) { entries.push(Entry { text: clean_line(line, word).to_string(), @@ -430,7 +469,11 @@ pub fn scan_readme_file(path: &Path, entries: &mut Vec) -> io::Result<()> // README.md can only have priority entries and generic entries entries.push(Entry { - text: line.trim_start().trim_start_matches("- [ ] ").trim_start_matches("- ").to_string(), + text: line + .trim_start() + .trim_start_matches("- [ ] ") + .trim_start_matches("- ") + .to_string(), location: Location { file: path.to_path_buf(), line: line_num + 1, @@ -470,59 +513,77 @@ mod tests { assert_eq!(6, entries.len()); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("foo"), - location: Location { - file: path.clone(), - line: 4, - } - }, entries[0]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("foo"), + location: Location { + file: path.clone(), + line: 4, + } + }, + entries[0] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("foo bar"), - location: Location { - file: path.clone(), - line: 5, - } - }, entries[1]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("foo bar"), + location: Location { + file: path.clone(), + line: 5, + } + }, + entries[1] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("baz"), - location: Location { - file: path.clone(), - line: 8, - } - }, entries[2]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("baz"), + location: Location { + file: path.clone(), + line: 8, + } + }, + entries[2] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("baz2"), - location: Location { - file: path.clone(), - line: 9, - } - }, entries[3]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("baz2"), + location: Location { + file: path.clone(), + line: 9, + } + }, + entries[3] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("baz2 todo"), - location: Location { - file: path.clone(), - line: 10, - } - }, entries[4]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("baz2 todo"), + location: Location { + file: path.clone(), + line: 10, + } + }, + entries[4] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("foo2"), - location: Location { - file: path.clone(), - line: 11, - } - }, entries[5]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("foo2"), + location: Location { + file: path.clone(), + line: 11, + } + }, + entries[5] + ); } #[test] @@ -548,70 +609,91 @@ mod tests { scan_string(str.to_string(), path.clone(), &mut entries); - assert_eq!(7, entries.len()); + assert_eq!(8, entries.len()); - assert_eq!(Entry { - data: EntryData::Category(String::from("foo")), - text: String::from(""), - location: Location { - file: path.clone(), - line: 4, - } - }, entries[0]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("foo")), + text: String::from(""), + location: Location { + file: path.clone(), + line: 4, + } + }, + entries[0] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("bar")), - text: String::from("abc def"), - location: Location { - file: path.clone(), - line: 5, - } - }, entries[1]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("bar")), + text: String::from("abc def"), + location: Location { + file: path.clone(), + line: 5, + } + }, + entries[1] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("baz")), - text: String::from("x y"), - location: Location { - file: path.clone(), - line: 7, - } - }, entries[2]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("baz")), + text: String::from("x y"), + location: Location { + file: path.clone(), + line: 7, + } + }, + entries[2] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("baz2")), - text: String::from("a"), - location: Location { - file: path.clone(), - line: 9, - } - }, entries[3]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("baz2")), + text: String::from("a"), + location: Location { + file: path.clone(), + line: 9, + } + }, + entries[3] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("baz3")), - text: String::from(""), - location: Location { - file: path.clone(), - line: 10, - } - }, entries[4]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("baz3")), + text: String::from(""), + location: Location { + file: path.clone(), + line: 10, + } + }, + entries[4] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("baz3")), - text: String::from("b"), - location: Location { - file: path.clone(), - line: 11, - } - }, entries[5]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("baz3")), + text: String::from("b"), + location: Location { + file: path.clone(), + line: 11, + } + }, + entries[5] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("baz3")), - text: String::from(""), - location: Location { - file: path.clone(), - line: 12, - } - }, entries[6]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("baz3")), + text: String::from(""), + location: Location { + file: path.clone(), + line: 12, + } + }, + entries[6] + ); assert_eq!( Entry { @@ -653,95 +735,125 @@ mod tests { assert_eq!(10, entries.len()); - assert_eq!(Entry { - data: EntryData::Priority(-1), - text: String::from(""), - location: Location { - file: path.clone(), - line: 4, - } - }, entries[0]); + assert_eq!( + Entry { + data: EntryData::Priority(-1), + text: String::from(""), + location: Location { + file: path.clone(), + line: 4, + } + }, + entries[0] + ); - assert_eq!(Entry { - data: EntryData::Priority(-2), - text: String::from("abc"), - location: Location { - file: path.clone(), - line: 5, - } - }, entries[1]); + assert_eq!( + Entry { + data: EntryData::Priority(-2), + text: String::from("abc"), + location: Location { + file: path.clone(), + line: 5, + } + }, + entries[1] + ); - assert_eq!(Entry { - data: EntryData::Priority(0), - text: String::from("abc def"), - location: Location { - file: path.clone(), - line: 6, - } - }, entries[2]); + assert_eq!( + Entry { + data: EntryData::Priority(0), + text: String::from("abc def"), + location: Location { + file: path.clone(), + line: 6, + } + }, + entries[2] + ); - assert_eq!(Entry { - data: EntryData::Priority(1), - text: String::from("foo"), - location: Location { - file: path.clone(), - line: 7, - } - }, entries[3]); + assert_eq!( + Entry { + data: EntryData::Priority(1), + text: String::from("foo"), + location: Location { + file: path.clone(), + line: 7, + } + }, + entries[3] + ); - assert_eq!(Entry { - data: EntryData::Priority(1), - text: String::from("x y"), - location: Location { - file: path.clone(), - line: 9, - } - }, entries[4]); + assert_eq!( + Entry { + data: EntryData::Priority(1), + text: String::from("x y"), + location: Location { + file: path.clone(), + line: 9, + } + }, + entries[4] + ); - assert_eq!(Entry { - data: EntryData::Priority(0), - text: String::from("bar"), - location: Location { - file: path.clone(), - line: 11, - } - }, entries[5]); + assert_eq!( + Entry { + data: EntryData::Priority(0), + text: String::from("bar"), + location: Location { + file: path.clone(), + line: 11, + } + }, + entries[5] + ); - assert_eq!(Entry { - data: EntryData::Priority(1), - text: String::from("a"), - location: Location { - file: path.clone(), - line: 12, - } - }, entries[6]); + assert_eq!( + Entry { + data: EntryData::Priority(1), + text: String::from("a"), + location: Location { + file: path.clone(), + line: 12, + } + }, + entries[6] + ); - assert_eq!(Entry { - data: EntryData::Priority(2), - text: String::from(""), - location: Location { - file: path.clone(), - line: 13, - } - }, entries[7]); + assert_eq!( + Entry { + data: EntryData::Priority(2), + text: String::from(""), + location: Location { + file: path.clone(), + line: 13, + } + }, + entries[7] + ); - assert_eq!(Entry { - data: EntryData::Priority(3), - text: String::from("b"), - location: Location { - file: path.clone(), - line: 14, - } - }, entries[8]); + assert_eq!( + Entry { + data: EntryData::Priority(3), + text: String::from("b"), + location: Location { + file: path.clone(), + line: 14, + } + }, + entries[8] + ); - assert_eq!(Entry { - data: EntryData::Priority(4), - text: String::from("b"), - location: Location { - file: path.clone(), - line: 15, - } - }, entries[9]); + assert_eq!( + Entry { + data: EntryData::Priority(4), + text: String::from("b"), + location: Location { + file: path.clone(), + line: 15, + } + }, + entries[9] + ); } #[test] @@ -756,95 +868,125 @@ mod tests { assert_eq!(10, entries.len()); - assert_eq!(Entry { - data: EntryData::Category(String::from("types")), - text: String::from(""), - location: Location { - file: path.clone(), - line: 1, - } - }, entries[0]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("types")), + text: String::from(""), + location: Location { + file: path.clone(), + line: 1, + } + }, + entries[0] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("types")), - text: String::from("add types"), - location: Location { - file: path.clone(), - line: 5, - } - }, entries[1]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("types")), + text: String::from("add types"), + location: Location { + file: path.clone(), + line: 5, + } + }, + entries[1] + ); - assert_eq!(Entry { - data: EntryData::Priority(-2), - text: String::from(""), - location: Location { - file: path.clone(), - line: 10, - } - }, entries[2]); + assert_eq!( + Entry { + data: EntryData::Priority(-2), + text: String::from(""), + location: Location { + file: path.clone(), + line: 10, + } + }, + entries[2] + ); - assert_eq!(Entry { - data: EntryData::Priority(-1), - text: String::from("add return typehint"), - location: Location { - file: path.clone(), - line: 14, - } - }, entries[3]); + assert_eq!( + Entry { + data: EntryData::Priority(-1), + text: String::from("add return typehint"), + location: Location { + file: path.clone(), + line: 14, + } + }, + entries[3] + ); - assert_eq!(Entry { - data: EntryData::Priority(0), - text: String::from("add name typehint"), - location: Location { - file: path.clone(), - line: 19, - } - }, entries[4]); + assert_eq!( + Entry { + data: EntryData::Priority(0), + text: String::from("add name typehint"), + location: Location { + file: path.clone(), + line: 19, + } + }, + entries[4] + ); - assert_eq!(Entry { - data: EntryData::Priority(1), - text: String::from("add return typehint"), - location: Location { - file: path.clone(), - line: 23, - } - }, entries[5]); + assert_eq!( + Entry { + data: EntryData::Priority(1), + text: String::from("add return typehint"), + location: Location { + file: path.clone(), + line: 23, + } + }, + entries[5] + ); - assert_eq!(Entry { - data: EntryData::Priority(2), - text: String::from("add return typehint"), - location: Location { - file: path.clone(), - line: 27, - } - }, entries[6]); + assert_eq!( + Entry { + data: EntryData::Priority(2), + text: String::from("add return typehint"), + location: Location { + file: path.clone(), + line: 27, + } + }, + entries[6] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from(""), - location: Location { - file: path.clone(), - line: 31, - } - }, entries[7]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from(""), + location: Location { + file: path.clone(), + line: 31, + } + }, + entries[7] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("generic todo 2"), - location: Location { - file: path.clone(), - line: 33, - } - }, entries[8]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("generic todo 2"), + location: Location { + file: path.clone(), + line: 33, + } + }, + entries[8] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("generic todo 3"), - location: Location { - file: path.clone(), - line: 34, - } - }, entries[9]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("generic todo 3"), + location: Location { + file: path.clone(), + line: 34, + } + }, + entries[9] + ); } #[test] @@ -859,41 +1001,53 @@ mod tests { assert_eq!(4, entries.len()); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("todo!(\"generic\");"), - location: Location { - file: path.clone(), - line: 3, - } - }, entries[0]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("todo!(\"generic\");"), + location: Location { + file: path.clone(), + line: 3, + } + }, + entries[0] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("todo!();"), - location: Location { - file: path.clone(), - line: 4, - } - }, entries[1]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("todo!();"), + location: Location { + file: path.clone(), + line: 4, + } + }, + entries[1] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("todo!(\"@foo not category\");"), - location: Location { - file: path.clone(), - line: 5, - } - }, entries[2]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("todo!(\"@foo not category\");"), + location: Location { + file: path.clone(), + line: 5, + } + }, + entries[2] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("todo!(\"00 not priority\");"), - location: Location { - file: path.clone(), - line: 6, - } - }, entries[3]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("todo!(\"00 not priority\");"), + location: Location { + file: path.clone(), + line: 6, + } + }, + entries[3] + ); } #[test] @@ -908,77 +1062,101 @@ mod tests { assert_eq!(8, entries.len()); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("generic foo"), - location: Location { - file: path.clone(), - line: 1, - } - }, entries[0]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("generic foo"), + location: Location { + file: path.clone(), + line: 1, + } + }, + entries[0] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("generic bar"), - location: Location { - file: path.clone(), - line: 2, - } - }, entries[1]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("generic bar"), + location: Location { + file: path.clone(), + line: 2, + } + }, + entries[1] + ); - assert_eq!(Entry { - data: EntryData::Priority(-1), - text: String::from("priority bar"), - location: Location { - file: path.clone(), - line: 3, - } - }, entries[2]); + assert_eq!( + Entry { + data: EntryData::Priority(-1), + text: String::from("priority bar"), + location: Location { + file: path.clone(), + line: 3, + } + }, + entries[2] + ); - assert_eq!(Entry { - data: EntryData::Priority(0), - text: String::from("a"), - location: Location { - file: path.clone(), - line: 6, - } - }, entries[3]); + assert_eq!( + Entry { + data: EntryData::Priority(0), + text: String::from("a"), + location: Location { + file: path.clone(), + line: 6, + } + }, + entries[3] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("High priority")), - text: String::from("foo"), - location: Location { - file: path.clone(), - line: 7, - } - }, entries[4]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("High priority")), + text: String::from("foo"), + location: Location { + file: path.clone(), + line: 7, + } + }, + entries[4] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("High priority")), - text: String::from("bar"), - location: Location { - file: path.clone(), - line: 8, - } - }, entries[5]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("High priority")), + text: String::from("bar"), + location: Location { + file: path.clone(), + line: 8, + } + }, + entries[5] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("Responsivity")), - text: String::from("abc"), - location: Location { - file: path.clone(), - line: 11, - } - }, entries[6]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("Responsivity")), + text: String::from("abc"), + location: Location { + file: path.clone(), + line: 11, + } + }, + entries[6] + ); - assert_eq!(Entry { - data: EntryData::Category(String::from("Responsivity")), - text: String::from("def"), - location: Location { - file: path.clone(), - line: 12, - } - }, entries[7]); + assert_eq!( + Entry { + data: EntryData::Category(String::from("Responsivity")), + text: String::from("def"), + location: Location { + file: path.clone(), + line: 12, + } + }, + entries[7] + ); } #[test] @@ -993,49 +1171,64 @@ mod tests { assert_eq!(5, entries.len()); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("abc"), - location: Location { - file: path.clone(), - line: 19, - } - }, entries[0]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("abc"), + location: Location { + file: path.clone(), + line: 19, + } + }, + entries[0] + ); - assert_eq!(Entry { - data: EntryData::Priority(0), - text: String::from("def"), - location: Location { - file: path.clone(), - line: 20, - } - }, entries[1]); + assert_eq!( + Entry { + data: EntryData::Priority(0), + text: String::from("def"), + location: Location { + file: path.clone(), + line: 20, + } + }, + entries[1] + ); - assert_eq!(Entry { - data: EntryData::Priority(-1), - text: String::from("ghi"), - location: Location { - file: path.clone(), - line: 21, - } - }, entries[2]); + assert_eq!( + Entry { + data: EntryData::Priority(-1), + text: String::from("ghi"), + location: Location { + file: path.clone(), + line: 21, + } + }, + entries[2] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("bar"), - location: Location { - file: path.clone(), - line: 22, - } - }, entries[3]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("bar"), + location: Location { + file: path.clone(), + line: 22, + } + }, + entries[3] + ); - assert_eq!(Entry { - data: EntryData::Generic, - text: String::from("baz"), - location: Location { - file: path.clone(), - line: 23, - } - }, entries[4]); + assert_eq!( + Entry { + data: EntryData::Generic, + text: String::from("baz"), + location: Location { + file: path.clone(), + line: 23, + } + }, + entries[4] + ); } }