Skip to content

Commit d4e9c20

Browse files
committed
Revert "Allow merging markmaps with different value types if there is a From impl"
This reverts commit 189bbfc.
1 parent 189bbfc commit d4e9c20

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

cfgrammar/src/lib/markmap.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,7 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
369369
/// For the behavior of exclusive or mark the behavior as also `Mark::Required`, then after merge call `missing()`
370370
/// to check all required values.
371371
#[doc(hidden)]
372-
pub fn merge_from<U>(&mut self, mut other: MarkMap<K, U>) -> Result<(), MergeError<K, Box<V>>>
373-
where V: From<U>
374-
{
372+
pub fn merge_from(&mut self, mut other: Self) -> Result<(), MergeError<K, Box<V>>> {
375373
for (their_key, their_mark, their_val) in other.contents.drain(..) {
376374
let pos = self.contents.binary_search_by(|x| x.0.cmp(&their_key));
377375
match pos {
@@ -390,21 +388,21 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
390388
if my_val.is_some() && their_val.is_some() {
391389
return Err(MergeError::Exclusivity(
392390
their_key,
393-
Box::new(their_val.unwrap().into()),
391+
Box::new(their_val.unwrap()),
394392
));
395393
} else if my_val.is_none() {
396-
*my_val = their_val.map(V::from);
394+
*my_val = their_val;
397395
}
398396
} else if merge_behavior == theirs_mark && their_val.is_some()
399397
|| merge_behavior == ours_mark && my_val.is_none()
400398
{
401399
*my_mark = their_mark;
402-
*my_val = their_val.map(V::from);
400+
*my_val = their_val;
403401
}
404402
}
405403
Err(pos) => {
406404
self.contents
407-
.insert(pos, (their_key, their_mark, their_val.map(V::from)));
405+
.insert(pos, (their_key, their_mark, their_val));
408406
}
409407
}
410408
}
@@ -698,7 +696,7 @@ mod test {
698696
fn test_merge_empty() {
699697
{
700698
let mut ours: MarkMap<&str, &str> = MarkMap::new();
701-
let theirs: MarkMap<&str, &str> = MarkMap::new();
699+
let theirs = MarkMap::new();
702700
assert!(ours.merge_from(theirs).is_ok());
703701
}
704702
{

0 commit comments

Comments
 (0)