Skip to content

Commit

Permalink
FilePatcher: return None when num_replacements is 0
Browse files Browse the repository at this point in the history
Fix #102
  • Loading branch information
dmerejkowsky committed Dec 3, 2022
1 parent c749858 commit ebbcfbe
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/file_patcher.rs
Expand Up @@ -62,12 +62,16 @@ impl FilePatcher {
}
}
}
Ok(Some(FilePatcher {
path: path.to_path_buf(),
new_contents,
num_lines,
num_replacements,
}))
if num_replacements == 0 {
Ok(None)
} else {
Ok(Some(FilePatcher {
path: path.to_path_buf(),
new_contents,
num_lines,
num_replacements,
}))
}
}

pub(crate) fn num_replacements(&self) -> usize {
Expand Down

0 comments on commit ebbcfbe

Please sign in to comment.