| 431 Q: Decomposition<B>, |
431 Q: Decomposition<B>, |
| 432 U: Instance<A, D>, |
432 U: Instance<A, D>, |
| 433 V: Instance<B, Q>, |
433 V: Instance<B, Q>, |
| 434 { |
434 { |
| 435 #[inline] |
435 #[inline] |
| 436 fn eval_decompose<'b, R>( |
436 fn eval_ref<'b, R>(&'b self, f: impl FnOnce(Pair<D::Reference<'b>, Q::Reference<'b>>) -> R) -> R |
| 437 self, |
|
| 438 f: impl FnOnce(Pair<D::Decomposition<'b>, Q::Decomposition<'b>>) -> R, |
|
| 439 ) -> R |
|
| 440 where |
437 where |
| 441 Pair<A, B>: 'b, |
438 Pair<A, B>: 'b, |
| 442 Self: 'b, |
439 Self: 'b, |
| 443 { |
440 { |
| 444 self.0 |
441 self.0.eval_ref(|a| self.1.eval_ref(|b| f(Pair(a, b)))) |
| 445 .eval_decompose(|a| self.1.eval_decompose(|b| f(Pair(a, b)))) |
|
| 446 } |
|
| 447 |
|
| 448 #[inline] |
|
| 449 fn eval_ref_decompose<'b, R>( |
|
| 450 &'b self, |
|
| 451 f: impl FnOnce(Pair<D::Reference<'b>, Q::Reference<'b>>) -> R, |
|
| 452 ) -> R |
|
| 453 where |
|
| 454 Pair<A, B>: 'b, |
|
| 455 Self: 'b, |
|
| 456 { |
|
| 457 self.0 |
|
| 458 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b)))) |
|
| 459 } |
442 } |
| 460 |
443 |
| 461 #[inline] |
444 #[inline] |
| 462 fn cow<'b>(self) -> MyCow<'b, Pair<A::Principal, B::Principal>> |
445 fn cow<'b>(self) -> MyCow<'b, Pair<A::Principal, B::Principal>> |
| 463 where |
446 where |
| 467 } |
450 } |
| 468 |
451 |
| 469 #[inline] |
452 #[inline] |
| 470 fn own(self) -> Pair<A::Principal, B::Principal> { |
453 fn own(self) -> Pair<A::Principal, B::Principal> { |
| 471 Pair(self.0.own(), self.1.own()) |
454 Pair(self.0.own(), self.1.own()) |
| |
455 } |
| |
456 |
| |
457 #[inline] |
| |
458 fn decompose<'b>(self) -> Pair<D::Decomposition<'b>, Q::Decomposition<'b>> |
| |
459 where |
| |
460 Self: 'b, |
| |
461 { |
| |
462 Pair(self.0.decompose(), self.1.decompose()) |
| 472 } |
463 } |
| 473 } |
464 } |
| 474 |
465 |
| 475 impl<'a, A, B, U, V, D, Q> Instance<Pair<A, B>, PairDecomposition<D, Q>> for &'a Pair<U, V> |
466 impl<'a, A, B, U, V, D, Q> Instance<Pair<A, B>, PairDecomposition<D, Q>> for &'a Pair<U, V> |
| 476 where |
467 where |
| 481 U: Instance<A, D>, |
472 U: Instance<A, D>, |
| 482 V: Instance<B, Q>, |
473 V: Instance<B, Q>, |
| 483 &'a U: Instance<A, D>, |
474 &'a U: Instance<A, D>, |
| 484 &'a V: Instance<B, Q>, |
475 &'a V: Instance<B, Q>, |
| 485 { |
476 { |
| 486 fn eval_decompose<'b, R>( |
477 fn eval_ref<'b, R>(&'b self, f: impl FnOnce(Pair<D::Reference<'b>, Q::Reference<'b>>) -> R) -> R |
| 487 self, |
|
| 488 f: impl FnOnce(Pair<D::Decomposition<'b>, Q::Decomposition<'b>>) -> R, |
|
| 489 ) -> R |
|
| 490 where |
478 where |
| 491 Pair<A, B>: 'b, |
479 Pair<A, B>: 'b, |
| 492 Self: 'b, |
480 Self: 'b, |
| 493 { |
481 { |
| 494 self.0.eval_ref_decompose(|a| { |
482 self.0.eval_ref(|a| self.1.eval_ref(|b| f(Pair(a, b)))) |
| 495 self.1 |
|
| 496 .eval_ref_decompose(|b| f(Pair(D::lift(a), Q::lift(b)))) |
|
| 497 }) |
|
| 498 } |
|
| 499 |
|
| 500 fn eval_ref_decompose<'b, R>( |
|
| 501 &'b self, |
|
| 502 f: impl FnOnce(Pair<D::Reference<'b>, Q::Reference<'b>>) -> R, |
|
| 503 ) -> R |
|
| 504 where |
|
| 505 Pair<A, B>: 'b, |
|
| 506 Self: 'b, |
|
| 507 { |
|
| 508 self.0 |
|
| 509 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b)))) |
|
| 510 } |
483 } |
| 511 |
484 |
| 512 #[inline] |
485 #[inline] |
| 513 fn cow<'b>(self) -> MyCow<'b, Pair<A::Principal, B::Principal>> |
486 fn cow<'b>(self) -> MyCow<'b, Pair<A::Principal, B::Principal>> |
| 514 where |
487 where |
| 519 |
492 |
| 520 #[inline] |
493 #[inline] |
| 521 fn own(self) -> Pair<A::Principal, B::Principal> { |
494 fn own(self) -> Pair<A::Principal, B::Principal> { |
| 522 let Pair(ref u, ref v) = self; |
495 let Pair(ref u, ref v) = self; |
| 523 Pair(u.own(), v.own()) |
496 Pair(u.own(), v.own()) |
| |
497 } |
| |
498 |
| |
499 #[inline] |
| |
500 fn decompose<'b>(self) -> Pair<D::Decomposition<'b>, Q::Decomposition<'b>> |
| |
501 where |
| |
502 Self: 'b, |
| |
503 { |
| |
504 let Pair(u, v) = self; |
| |
505 Pair(u.decompose(), v.decompose()) |
| 524 } |
506 } |
| 525 } |
507 } |
| 526 |
508 |
| 527 impl<A, B, D, Q> DecompositionMut<Pair<A, B>> for PairDecomposition<D, Q> |
509 impl<A, B, D, Q> DecompositionMut<Pair<A, B>> for PairDecomposition<D, Q> |
| 528 where |
510 where |