Struct ruplacer::FilePatcher
source · [−]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
Auto Trait Implementations
impl RefUnwindSafe for FilePatcher
impl Send for FilePatcher
impl Sync for FilePatcher
impl Unpin for FilePatcher
impl UnwindSafe for FilePatcher
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more