pub struct Change {
pub file_path: PathBuf,
pub unit: SemanticUnit,
pub classification: CodeType,
pub lines_added: usize,
pub lines_removed: usize,
}Expand description
A change to a semantic unit
Fields§
§file_path: PathBufPath to the file containing the change
unit: SemanticUnitThe semantic unit that was changed
classification: CodeTypeClassification of the code
lines_added: usizeNumber of lines added
lines_removed: usizeNumber of lines removed
Implementations§
Source§impl Change
impl Change
Sourcepub fn new(
file_path: PathBuf,
unit: SemanticUnit,
classification: CodeType,
lines_added: usize,
lines_removed: usize,
) -> Self
pub fn new( file_path: PathBuf, unit: SemanticUnit, classification: CodeType, lines_added: usize, lines_removed: usize, ) -> Self
Creates a new change
§Arguments
file_path- Path to the fileunit- The semantic unit that was changedclassification- Classification of the codelines_added- Number of lines addedlines_removed- Number of lines removed
§Returns
A new Change instance
§Examples
use std::path::PathBuf;
use rust_diff_analyzer::types::{
Change, CodeType, LineSpan, SemanticUnit, SemanticUnitKind, Visibility,
};
let unit = SemanticUnit::new(
SemanticUnitKind::Function,
"parse".to_string(),
Visibility::Public,
LineSpan::new(10, 30),
vec![],
);
let change = Change::new(
PathBuf::from("src/parser.rs"),
unit,
CodeType::Production,
10,
5,
);
assert_eq!(change.lines_added, 10);Sourcepub fn total_lines(&self) -> usize
pub fn total_lines(&self) -> usize
Returns total lines changed (added + removed)
§Returns
Sum of lines added and removed
§Examples
use std::path::PathBuf;
use rust_diff_analyzer::types::{
Change, CodeType, LineSpan, SemanticUnit, SemanticUnitKind, Visibility,
};
let unit = SemanticUnit::new(
SemanticUnitKind::Function,
"parse".to_string(),
Visibility::Public,
LineSpan::new(10, 30),
vec![],
);
let change = Change::new(
PathBuf::from("src/parser.rs"),
unit,
CodeType::Production,
10,
5,
);
assert_eq!(change.total_lines(), 15);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Change
impl<'de> Deserialize<'de> for Change
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Change
impl StructuralPartialEq for Change
Auto Trait Implementations§
impl Freeze for Change
impl RefUnwindSafe for Change
impl Send for Change
impl Sync for Change
impl Unpin for Change
impl UnwindSafe for Change
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