diff options
author | Teddy Wing | 2020-09-16 01:46:41 +0200 |
---|---|---|
committer | Teddy Wing | 2020-09-16 01:46:41 +0200 |
commit | cefd5dc50548b846b2f383c1a0d2a5168cd2553a (patch) | |
tree | effe9d78f7a1c078d7fd8b2c92b6010cbd59fc82 /src/lib.rs | |
parent | b0aa9334017e433225175d323732472c35f51aed (diff) | |
download | git-todo-cefd5dc50548b846b2f383c1a0d2a5168cd2553a.tar.bz2 |
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.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,9 +1,11 @@ #![warn(rust_2018_idioms)] +use std::io::Write; + use git2::Repository; -pub fn write_since() { +pub fn write_since<W: Write>(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(); } } |