src/direct_product.rs

branch
dev
changeset 155
45d03cf92c23
parent 151
402d717bb5c0
child 162
bea0c3841ced
equal deleted inserted replaced
154:03f34ba55685 155:45d03cf92c23
390 A: Space, 390 A: Space,
391 B: Space, 391 B: Space,
392 D: Decomposition<A>, 392 D: Decomposition<A>,
393 Q: Decomposition<B>, 393 Q: Decomposition<B>,
394 { 394 {
395 type OwnedInstance = Pair<D::OwnedInstance, Q::OwnedInstance>;
396
395 type Decomposition<'b> 397 type Decomposition<'b>
396 = Pair<D::Decomposition<'b>, Q::Decomposition<'b>> 398 = Pair<D::Decomposition<'b>, Q::Decomposition<'b>>
397 where 399 where
398 Pair<A, B>: 'b; 400 Pair<A, B>: 'b;
399 type Reference<'b> 401 type Reference<'b>
439 self.0 441 self.0
440 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b)))) 442 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b))))
441 } 443 }
442 444
443 #[inline] 445 #[inline]
444 fn cow<'b>(self) -> MyCow<'b, Pair<A, B>> 446 fn cow<'b>(self) -> MyCow<'b, Pair<D::OwnedInstance, Q::OwnedInstance>>
445 where 447 where
446 Self: 'b, 448 Self: 'b,
447 { 449 {
448 MyCow::Owned(Pair(self.0.own(), self.1.own())) 450 MyCow::Owned(Pair(self.0.own(), self.1.own()))
449 } 451 }
450 452
451 #[inline] 453 #[inline]
452 fn own(self) -> Pair<A, B> { 454 fn own(self) -> Pair<D::OwnedInstance, Q::OwnedInstance> {
453 Pair(self.0.own(), self.1.own()) 455 Pair(self.0.own(), self.1.own())
454 } 456 }
455 } 457 }
456 458
457 impl<'a, A, B, U, V, D, Q> Instance<Pair<A, B>, PairDecomposition<D, Q>> for &'a Pair<U, V> 459 impl<'a, A, B, U, V, D, Q> Instance<Pair<A, B>, PairDecomposition<D, Q>> for &'a Pair<U, V>
490 self.0 492 self.0
491 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b)))) 493 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b))))
492 } 494 }
493 495
494 #[inline] 496 #[inline]
495 fn cow<'b>(self) -> MyCow<'b, Pair<A, B>> 497 fn cow<'b>(self) -> MyCow<'b, Pair<D::OwnedInstance, Q::OwnedInstance>>
496 where 498 where
497 Self: 'b, 499 Self: 'b,
498 { 500 {
499 MyCow::Owned(self.own()) 501 MyCow::Owned(self.own())
500 } 502 }
501 503
502 #[inline] 504 #[inline]
503 fn own(self) -> Pair<A, B> { 505 fn own(self) -> Pair<D::OwnedInstance, Q::OwnedInstance> {
504 let Pair(ref u, ref v) = self; 506 let Pair(ref u, ref v) = self;
505 Pair(u.own(), v.own()) 507 Pair(u.own(), v.own())
506 } 508 }
507 } 509 }
508 510

mercurial