pub struct FileDiff {
pub path: PathBuf,
pub old_path: Option<PathBuf>,
pub is_deleted: bool,
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)
is_deleted: boolWhether the file was deleted in this diff
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 all_removed_positions_in_new(&self) -> Vec<usize>
pub fn all_removed_positions_in_new(&self) -> Vec<usize>
Returns new-file line positions of all removals across hunks
See Hunk::removed_positions_in_new for the attribution rule.
§Returns
Vector of new-file line numbers, one per removed line
§Examples
use std::path::PathBuf;
use rust_diff_analyzer::git::FileDiff;
let diff = FileDiff::new(PathBuf::from("src/lib.rs"));
assert!(diff.all_removed_positions_in_new().is_empty());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 UnsafeUnpin 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