Skip to content

Commit

Permalink
Update: reformat codes
Browse files Browse the repository at this point in the history
  • Loading branch information
james-wangx committed Apr 9, 2022
1 parent f48c703 commit c2ff5aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ pub struct Args {
impl Args {
pub fn replace(&self, target: &str) -> Result<(), Box<dyn Error>> {
let md = fs::metadata(target)?;

if md.is_file() {
let contents = fs::read_to_string(target)?;
let results = contents.replace(&self.string, &self.switch);
fs::write(target, results)?;
println!("Replaced in file {}", target);
return Ok(());
return Ok(());
} else {
for entry in fs::read_dir(target)? {
let path = entry?.path();
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use replace::Args;
fn main() {
let args = Args::parse();


if let Err(e) = args.replace(args.get_target()) {
eprintln!("Application error: {}", e);
process::exit(1);
Expand Down

0 comments on commit c2ff5aa

Please sign in to comment.