pub struct HunkLine {
pub line_type: LineType,
pub old_line: Option<usize>,
pub new_line: Option<usize>,
pub content: String,
}Expand description
A single line in a diff hunk
Fields§
§line_type: LineTypeType of the line
old_line: Option<usize>Line number in original file (for removed/context)
new_line: Option<usize>Line number in new file (for added/context)
content: StringContent of the line
Implementations§
Source§impl HunkLine
impl HunkLine
Sourcepub fn context(old_line: usize, new_line: usize, content: String) -> Self
pub fn context(old_line: usize, new_line: usize, content: String) -> Self
Creates a new context line
§Arguments
old_line- Line number in original filenew_line- Line number in new filecontent- Content of the line
§Returns
A new HunkLine for a context line
§Examples
use rust_diff_analyzer::git::HunkLine;
let line = HunkLine::context(5, 6, "fn main() {".to_string());
assert_eq!(line.old_line, Some(5));
assert_eq!(line.new_line, Some(6));Sourcepub fn is_removed(&self) -> bool
pub fn is_removed(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for HunkLine
impl<'de> Deserialize<'de> for HunkLine
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 HunkLine
impl StructuralPartialEq for HunkLine
Auto Trait Implementations§
impl Freeze for HunkLine
impl RefUnwindSafe for HunkLine
impl Send for HunkLine
impl Sync for HunkLine
impl Unpin for HunkLine
impl UnwindSafe for HunkLine
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