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,9 +67,15 @@ 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)) => {
|
||||||
|
if a.id() != b.id() {
|
||||||
panic!("Can't merge two full objects")
|
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),
|
||||||
(Self::Partial(a), Self::Partial(b)) => {
|
(Self::Partial(a), Self::Partial(b)) => {
|
||||||
|
|
Loading…
Reference in New Issue