pub struct FileDiff {
pub path: PathBuf,
pub old_path: Option<PathBuf>,
pub hunks: Vec<Hunk>,
}Expand description
A file diff containing all hunks for a single file
Fields§
§path: PathBufPath to the file (new path if renamed)
old_path: Option<PathBuf>Original path (if renamed)
hunks: Vec<Hunk>Hunks in this file diff
Implementations§
Source§impl FileDiff
impl FileDiff
Sourcepub fn total_added(&self) -> usize
pub fn total_added(&self) -> usize
Sourcepub fn total_removed(&self) -> usize
pub fn total_removed(&self) -> usize
Sourcepub fn all_added_lines(&self) -> Vec<usize>
pub fn all_added_lines(&self) -> Vec<usize>
Sourcepub fn all_removed_lines(&self) -> Vec<usize>
pub fn all_removed_lines(&self) -> Vec<usize>
Sourcepub fn is_rust_file(&self) -> bool
pub fn is_rust_file(&self) -> bool
Checks if file path ends with .rs extension
§Returns
true if file is a Rust source file
§Examples
use std::path::PathBuf;
use rust_diff_analyzer::git::FileDiff;
let diff = FileDiff::new(PathBuf::from("src/lib.rs"));
assert!(diff.is_rust_file());
let diff = FileDiff::new(PathBuf::from("README.md"));
assert!(!diff.is_rust_file());Trait Implementations§
impl Eq for FileDiff
impl StructuralPartialEq for FileDiff
Auto Trait Implementations§
impl Freeze for FileDiff
impl RefUnwindSafe for FileDiff
impl Send for FileDiff
impl Sync for FileDiff
impl Unpin for FileDiff
impl UnwindSafe for FileDiff
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more