From cefd5dc50548b846b2f383c1a0d2a5168cd2553a Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 16 Sep 2020 01:46:41 +0200 Subject: write_since(): Take an arbitrary `Write`r Instead of always printing to standard output, have the function take a writer to write the output to. --- src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 46e0fc8..1b9689a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,11 @@ #![warn(rust_2018_idioms)] +use std::io::Write; + use git2::Repository; -pub fn write_since() { +pub fn write_since(write_to: &mut W) { let repo = Repository::open(".").unwrap(); // let head = repo.head().unwrap().target().unwrap(); @@ -32,12 +34,13 @@ pub fn write_since() { let l = std::str::from_utf8(line.content()).unwrap(); if l.contains("TODO") { - print!( + write!( + write_to, "{}:{}:{}", delta.new_file().path().unwrap().display(), line_number, l, - ); + ).unwrap(); } } -- cgit v1.2.3