src/direct_product.rs

branch
dev
changeset 162
bea0c3841ced
parent 155
45d03cf92c23
child 164
fd9dba51afd3
equal deleted inserted replaced
160:e7920e205785 162:bea0c3841ced
273 #[inline] 273 #[inline]
274 fn into_owned(self) -> Self::OwnedVariant { 274 fn into_owned(self) -> Self::OwnedVariant {
275 Pair(self.0.into_owned(), self.1.into_owned()) 275 Pair(self.0.into_owned(), self.1.into_owned())
276 } 276 }
277 277
278 /// Returns an owned instance of a reference. 278 #[inline]
279 fn clone_owned(&self) -> Self::OwnedVariant { 279 fn clone_owned(&self) -> Self::OwnedVariant {
280 Pair(self.0.clone_owned(), self.1.clone_owned()) 280 Pair(self.0.clone_owned(), self.1.clone_owned())
281 }
282
283 #[inline]
284 fn cow_owned<'b>(self) -> MyCow<'b, Self::OwnedVariant>
285 where
286 Self: 'b,
287 {
288 MyCow::Owned(self.into_owned())
281 } 289 }
282 } 290 }
283 291
284 /// We only support 'closed' `Euclidean` `Pair`s, as more general ones cause 292 /// We only support 'closed' `Euclidean` `Pair`s, as more general ones cause
285 /// compiler overflows. 293 /// compiler overflows.
390 A: Space, 398 A: Space,
391 B: Space, 399 B: Space,
392 D: Decomposition<A>, 400 D: Decomposition<A>,
393 Q: Decomposition<B>, 401 Q: Decomposition<B>,
394 { 402 {
395 type OwnedInstance = Pair<D::OwnedInstance, Q::OwnedInstance>;
396
397 type Decomposition<'b> 403 type Decomposition<'b>
398 = Pair<D::Decomposition<'b>, Q::Decomposition<'b>> 404 = Pair<D::Decomposition<'b>, Q::Decomposition<'b>>
399 where 405 where
400 Pair<A, B>: 'b; 406 Pair<A, B>: 'b;
401 type Reference<'b> 407 type Reference<'b>
441 self.0 447 self.0
442 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b)))) 448 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b))))
443 } 449 }
444 450
445 #[inline] 451 #[inline]
446 fn cow<'b>(self) -> MyCow<'b, Pair<D::OwnedInstance, Q::OwnedInstance>> 452 fn cow<'b>(self) -> MyCow<'b, Pair<A::OwnedSpace, B::OwnedSpace>>
447 where 453 where
448 Self: 'b, 454 Self: 'b,
449 { 455 {
450 MyCow::Owned(Pair(self.0.own(), self.1.own())) 456 MyCow::Owned(Pair(self.0.own(), self.1.own()))
451 } 457 }
452 458
453 #[inline] 459 #[inline]
454 fn own(self) -> Pair<D::OwnedInstance, Q::OwnedInstance> { 460 fn own(self) -> Pair<A::OwnedSpace, B::OwnedSpace> {
455 Pair(self.0.own(), self.1.own()) 461 Pair(self.0.own(), self.1.own())
456 } 462 }
457 } 463 }
458 464
459 impl<'a, A, B, U, V, D, Q> Instance<Pair<A, B>, PairDecomposition<D, Q>> for &'a Pair<U, V> 465 impl<'a, A, B, U, V, D, Q> Instance<Pair<A, B>, PairDecomposition<D, Q>> for &'a Pair<U, V>
492 self.0 498 self.0
493 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b)))) 499 .eval_ref_decompose(|a| self.1.eval_ref_decompose(|b| f(Pair(a, b))))
494 } 500 }
495 501
496 #[inline] 502 #[inline]
497 fn cow<'b>(self) -> MyCow<'b, Pair<D::OwnedInstance, Q::OwnedInstance>> 503 fn cow<'b>(self) -> MyCow<'b, Pair<A::OwnedSpace, B::OwnedSpace>>
498 where 504 where
499 Self: 'b, 505 Self: 'b,
500 { 506 {
501 MyCow::Owned(self.own()) 507 MyCow::Owned(self.own())
502 } 508 }
503 509
504 #[inline] 510 #[inline]
505 fn own(self) -> Pair<D::OwnedInstance, Q::OwnedInstance> { 511 fn own(self) -> Pair<A::OwnedSpace, B::OwnedSpace> {
506 let Pair(ref u, ref v) = self; 512 let Pair(ref u, ref v) = self;
507 Pair(u.own(), v.own()) 513 Pair(u.own(), v.own())
508 } 514 }
509 } 515 }
510 516

mercurial