mirror of https://github.com/hannobraun/Fornjot
Don't panic, when merging identical full objects
This commit is contained in:
parent
8ede469d00
commit
41b32978b7
|
@ -67,8 +67,14 @@ impl<T: HasPartial> MaybePartial<T> {
|
||||||
/// Merge this `MaybePartial` with another of the same type
|
/// Merge this `MaybePartial` with another of the same type
|
||||||
pub fn merge_with(self, other: impl Into<Self>) -> Self {
|
pub fn merge_with(self, other: impl Into<Self>) -> Self {
|
||||||
match (self, other.into()) {
|
match (self, other.into()) {
|
||||||
(Self::Full(_), Self::Full(_)) => {
|
(Self::Full(a), Self::Full(b)) => {
|
||||||
panic!("Can't merge two full objects")
|
if a.id() != b.id() {
|
||||||
|
panic!("Can't merge two full objects")
|
||||||
|
}
|
||||||
|
|
||||||
|
// If they're equal, which they are, if we reach this point,
|
||||||
|
// then merging them is a no-op.
|
||||||
|
Self::Full(a)
|
||||||
}
|
}
|
||||||
(Self::Full(full), Self::Partial(_))
|
(Self::Full(full), Self::Partial(_))
|
||||||
| (Self::Partial(_), Self::Full(full)) => Self::Full(full),
|
| (Self::Partial(_), Self::Full(full)) => Self::Full(full),
|
||||||
|
|
Loading…
Reference in New Issue