pub struct FilePatcher { /* private fields */ }
Expand description

Run replacement query on a given file

Example, assuming the data.txt file contains ‘This is my old car’

use ruplacer::{Console, FilePatcher, Query};
use std::path::PathBuf;

let file = PathBuf::from("data.txt");
let query = Query::substring("old", "new");
let console = Console::new();
let file_patcher = FilePatcher::new(&console, &file, &query).unwrap();
file_patcher.unwrap().run().unwrap();

let new_contents = std::fs::read_to_string("data.txt").unwrap();
assert_eq!(new_contents, "This is my new car.");

Implementations

Write new contents to the file.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.