pub struct Diff { /* private fields */ }
Expand description
The serializable representation of a git diff
.
A Diff
can be retrieved by the following functions:
Implementations§
Source§impl Diff
impl Diff
Sourcepub fn files(&self) -> impl Iterator<Item = &FileDiff>
pub fn files(&self) -> impl Iterator<Item = &FileDiff>
Returns an iterator of the file in the diff.
Sourcepub fn into_files(self) -> Vec<FileDiff>
pub fn into_files(self) -> Vec<FileDiff>
Returns owned files in the diff.
Sourcepub fn added(&self) -> impl Iterator<Item = &Added>
pub fn added(&self) -> impl Iterator<Item = &Added>
Examples found in repository?
examples/diff.rs (line 60)
59fn print_diff_summary(diff: &Diff, elapsed_nanos: u128) {
60 diff.added().for_each(|created| {
61 println!("+++ {:?}", created.path);
62 });
63 diff.deleted().for_each(|deleted| {
64 println!("--- {:?}", deleted.path);
65 });
66 diff.modified().for_each(|modified| {
67 println!("mod {:?}", modified.path);
68 });
69
70 println!(
71 "created {} / deleted {} / modified {} / total {}",
72 diff.added().count(),
73 diff.deleted().count(),
74 diff.modified().count(),
75 diff.added().count() + diff.deleted().count() + diff.modified().count()
76 );
77 println!("diff took {elapsed_nanos} nanos ");
78}
Sourcepub fn deleted(&self) -> impl Iterator<Item = &Deleted>
pub fn deleted(&self) -> impl Iterator<Item = &Deleted>
Examples found in repository?
examples/diff.rs (line 63)
59fn print_diff_summary(diff: &Diff, elapsed_nanos: u128) {
60 diff.added().for_each(|created| {
61 println!("+++ {:?}", created.path);
62 });
63 diff.deleted().for_each(|deleted| {
64 println!("--- {:?}", deleted.path);
65 });
66 diff.modified().for_each(|modified| {
67 println!("mod {:?}", modified.path);
68 });
69
70 println!(
71 "created {} / deleted {} / modified {} / total {}",
72 diff.added().count(),
73 diff.deleted().count(),
74 diff.modified().count(),
75 diff.added().count() + diff.deleted().count() + diff.modified().count()
76 );
77 println!("diff took {elapsed_nanos} nanos ");
78}
pub fn moved(&self) -> impl Iterator<Item = &Moved>
Sourcepub fn modified(&self) -> impl Iterator<Item = &Modified>
pub fn modified(&self) -> impl Iterator<Item = &Modified>
Examples found in repository?
examples/diff.rs (line 66)
59fn print_diff_summary(diff: &Diff, elapsed_nanos: u128) {
60 diff.added().for_each(|created| {
61 println!("+++ {:?}", created.path);
62 });
63 diff.deleted().for_each(|deleted| {
64 println!("--- {:?}", deleted.path);
65 });
66 diff.modified().for_each(|modified| {
67 println!("mod {:?}", modified.path);
68 });
69
70 println!(
71 "created {} / deleted {} / modified {} / total {}",
72 diff.added().count(),
73 diff.deleted().count(),
74 diff.modified().count(),
75 diff.added().count() + diff.deleted().count() + diff.modified().count()
76 );
77 println!("diff took {elapsed_nanos} nanos ");
78}
pub fn copied(&self) -> impl Iterator<Item = &Copied>
pub fn stats(&self) -> &Stats
pub fn insert_modified( &mut self, path: PathBuf, diff: DiffContent, old: DiffFile, new: DiffFile, )
pub fn insert_moved( &mut self, old_path: PathBuf, new_path: PathBuf, old: DiffFile, new: DiffFile, content: DiffContent, )
pub fn insert_copied( &mut self, old_path: PathBuf, new_path: PathBuf, old: DiffFile, new: DiffFile, content: DiffContent, )
pub fn insert_added(&mut self, path: PathBuf, diff: DiffContent, new: DiffFile)
pub fn insert_deleted( &mut self, path: PathBuf, diff: DiffContent, old: DiffFile, )
Trait Implementations§
impl Eq for Diff
impl StructuralPartialEq for Diff
Auto Trait Implementations§
impl Freeze for Diff
impl RefUnwindSafe for Diff
impl Send for Diff
impl Sync for Diff
impl Unpin for Diff
impl UnwindSafe for Diff
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