Added missing docs
This commit is contained in:
parent
7abcdc09d8
commit
158c28784d
6 changed files with 25 additions and 1 deletions
|
|
@ -9,27 +9,40 @@ use std::ops::Range;
|
|||
pub enum DiffOp {
|
||||
/// A segment is equal (see [`DiffHook::equal`])
|
||||
Equal {
|
||||
/// The starting index in the old sequence.
|
||||
old_index: usize,
|
||||
/// The starting index in the new sequence.
|
||||
new_index: usize,
|
||||
/// The length of the segment.
|
||||
len: usize,
|
||||
},
|
||||
/// A segment was deleted (see [`DiffHook::delete`])
|
||||
Delete {
|
||||
/// The starting index in the old sequence.
|
||||
old_index: usize,
|
||||
/// The length of the old segment.
|
||||
old_len: usize,
|
||||
/// The starting index in the new sequence.
|
||||
new_index: usize,
|
||||
},
|
||||
/// A segment was inserted (see [`DiffHook::insert`])
|
||||
Insert {
|
||||
/// The starting index in the old sequence.
|
||||
old_index: usize,
|
||||
/// The starting index in the new sequence.
|
||||
new_index: usize,
|
||||
/// The length of the new segment.
|
||||
new_len: usize,
|
||||
},
|
||||
/// A segment was replaced (see [`DiffHook::replace`])
|
||||
Replace {
|
||||
/// The starting index in the old sequence.
|
||||
old_index: usize,
|
||||
/// The length of the old segment.
|
||||
old_len: usize,
|
||||
/// The starting index in the new sequence.
|
||||
new_index: usize,
|
||||
/// The length of the new segment.
|
||||
new_len: usize,
|
||||
},
|
||||
}
|
||||
|
|
@ -37,9 +50,13 @@ pub enum DiffOp {
|
|||
/// The tag of a diff operation.
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)]
|
||||
pub enum DiffTag {
|
||||
/// The diff op encodes an equal segment.
|
||||
Equal,
|
||||
/// The diff op encodes a deleted segment.
|
||||
Delete,
|
||||
/// The diff op encodes an inserted segment.
|
||||
Insert,
|
||||
/// The diff op encodes a replaced segment.
|
||||
Replace,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/// A trait for reacting to an edit script from the "old" version to
|
||||
/// the "new" version.
|
||||
pub trait DiffHook: Sized {
|
||||
/// The error produced from the hook methods.
|
||||
type Error;
|
||||
|
||||
/// Called when lines with indices `old_index` (in the old version) and
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ pub mod patience;
|
|||
/// An enum representing a diffing algorithm.
|
||||
#[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
pub enum Algorithm {
|
||||
/// Picks the myers algorithm from [`myers`]
|
||||
Myers,
|
||||
/// Picks the patience algorithm from [`patience`]
|
||||
Patience,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,5 +43,6 @@
|
|||
//! is particularly useful when working with text containing emojis.
|
||||
//! * `text`: this feature is enabled by default and enables the [`text`] module.
|
||||
//! If the crate is used without default features it's removed.
|
||||
#![warn(missing_docs)]
|
||||
pub mod algorithms;
|
||||
pub mod text;
|
||||
|
|
|
|||
|
|
@ -215,8 +215,11 @@ pub struct TextDiff<'old, 'new, 'bufs> {
|
|||
/// The tag of a change.
|
||||
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)]
|
||||
pub enum ChangeTag {
|
||||
/// The change indicates equality (not a change)
|
||||
Equal,
|
||||
/// The change indicates deleted text.
|
||||
Delete,
|
||||
/// The change indicates inserted text.
|
||||
Insert,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ impl<'diff, 'old, 'new, 'bufs> fmt::Display for UnifiedDiffHunk<'diff, 'old, 'ne
|
|||
if self.missing_newline_hint {
|
||||
writeln!(f, "\n\\ No newline at end of file")?;
|
||||
} else {
|
||||
writeln!(f, "")?;
|
||||
writeln!(f)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue