pub struct Conflict<T> { /* private fields */ }
Expand description
A generic representation of conflicting values.
There is exactly one more adds()
than removes()
. When interpreted as a
series of diffs, the conflict’s (i+1)-st add is matched with the i-th
remove. The zeroth add is considered a diff from the non-existent state.
Implementations§
source§impl<T> Conflict<T>
impl<T> Conflict<T>
pub fn new(removes: Vec<T>, adds: Vec<T>) -> Self
pub fn resolved(value: T) -> Self
sourcepub fn from_legacy_form(
removes: impl IntoIterator<Item = T>,
adds: impl IntoIterator<Item = T>
) -> Conflict<Option<T>>
pub fn from_legacy_form( removes: impl IntoIterator<Item = T>, adds: impl IntoIterator<Item = T> ) -> Conflict<Option<T>>
Create a Conflict
from a removes
and adds
, padding with None
to
make sure that there is exactly one more adds
than removes
.
pub fn removes(&self) -> &[T]
pub fn adds(&self) -> &[T]
sourcepub fn as_resolved(&self) -> Option<&T>
pub fn as_resolved(&self) -> Option<&T>
Returns the resolved value, if this conflict is resolved. Does not resolve trivial conflicts.
sourcepub fn simplify(self) -> Selfwhere
T: PartialEq,
pub fn simplify(self) -> Selfwhere T: PartialEq,
Simplify the conflict by joining diffs like A->B and B->C into A->C. Also drops trivial diffs like A->A.
pub fn resolve_trivial(&self) -> Option<&T>where T: Eq + Hash,
sourcepub fn map<'a, U>(&'a self, f: impl FnMut(&'a T) -> U) -> Conflict<U>
pub fn map<'a, U>(&'a self, f: impl FnMut(&'a T) -> U) -> Conflict<U>
Creates a new conflict by applying f
to each remove and add.
source§impl<T> Conflict<Option<T>>
impl<T> Conflict<Option<T>>
sourcepub fn into_legacy_form(self) -> (Vec<T>, Vec<T>)
pub fn into_legacy_form(self) -> (Vec<T>, Vec<T>)
Creates lists of removes
and adds
from a Conflict
by dropping
None
values. Note that the conversion is lossy: the order of None
values is not preserved when converting back to a Conflict
.
source§impl Conflict<Option<TreeValue>>
impl Conflict<Option<TreeValue>>
sourcepub fn from_backend_conflict(conflict: Conflict) -> Self
pub fn from_backend_conflict(conflict: Conflict) -> Self
Create a Conflict
from a backend::Conflict
, padding with None
to
make sure that there is exactly one more adds()
than removes()
.
sourcepub fn into_backend_conflict(self) -> Conflict
pub fn into_backend_conflict(self) -> Conflict
Creates a backend::Conflict
from a Conflict
by dropping None
values. Note that the conversion is lossy: the order of None
values is
not preserved when converting back to a Conflict
.
pub fn materialize( &self, store: &Store, path: &RepoPath, output: &mut dyn Write ) -> Result<()>
pub fn to_file_conflict(&self) -> Option<Conflict<Option<FileId>>>
sourcepub fn describe(&self, file: &mut dyn Write) -> Result<()>
pub fn describe(&self, file: &mut dyn Write) -> Result<()>
Give a summary description of the conflict’s “removes” and “adds”
sourcepub fn update_from_content(
&self,
store: &Store,
path: &RepoPath,
content: &[u8]
) -> BackendResult<Option<Conflict<Option<TreeValue>>>>
pub fn update_from_content( &self, store: &Store, path: &RepoPath, content: &[u8] ) -> BackendResult<Option<Conflict<Option<TreeValue>>>>
Returns None
if there are no conflict markers in content
.