pub type Resolver = Box<dyn Fn(&Conflict) -> Resolution>;Expand description
Conflict resolution strategy
A function that takes a conflict and returns an explicit resolution.
If Resolution::Unresolved is returned, the merge will fail with a
Conflict error.
§Example
use prolly::{Resolution, Resolver};
// Always prefer the left value
let prefer_left: Resolver = Box::new(|conflict| {
match &conflict.left {
Some(value) => Resolution::value(value.clone()),
None => Resolution::delete(),
}
});
// Always prefer the right value
let prefer_right: Resolver = Box::new(|conflict| {
match &conflict.right {
Some(value) => Resolution::value(value.clone()),
None => Resolution::delete(),
}
});
// Concatenate values
let concat: Resolver = Box::new(|conflict| {
match (&conflict.left, &conflict.right) {
(Some(left), Some(right)) => {
let mut result = left.clone();
result.extend(right);
Resolution::value(result)
}
_ => Resolution::unresolved(),
}
});Aliased Type§
pub struct Resolver(/* private fields */);