| 162:bea0c3841ced | 163:b4a47e8e80d1 |
|---|---|
| 191 /// Most common [`Decomposition`] (into `Either<X, &'b X>`) that allows working with owned | 191 /// Most common [`Decomposition`] (into `Either<X, &'b X>`) that allows working with owned |
| 192 /// values and all sorts of references. | 192 /// values and all sorts of references. |
| 193 #[derive(Copy, Clone, Debug)] | 193 #[derive(Copy, Clone, Debug)] |
| 194 pub struct BasicDecomposition; | 194 pub struct BasicDecomposition; |
| 195 | 195 |
| 196 impl<X: Space + Clone> Decomposition<X> for BasicDecomposition { | 196 impl<X: Space> Decomposition<X> for BasicDecomposition { |
| 197 type Decomposition<'b> | 197 type Decomposition<'b> |
| 198 = MyCow<'b, X> | 198 = MyCow<'b, X> |
| 199 where | 199 where |
| 200 X: 'b; | 200 X: 'b; |
| 201 type Reference<'b> | 201 type Reference<'b> |
| 280 EitherDecomp::Borrowed(x) => g(x), | 280 EitherDecomp::Borrowed(x) => g(x), |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 | 284 |
| 285 impl<X: Space + Clone> Instance<X, BasicDecomposition> for X { | 285 impl<X: Space> Instance<X, BasicDecomposition> for X { |
| 286 #[inline] | 286 #[inline] |
| 287 fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R | 287 fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R |
| 288 where | 288 where |
| 289 X: 'b, | 289 X: 'b, |
| 290 Self: 'b, | 290 Self: 'b, |
| 300 { | 300 { |
| 301 f(self) | 301 f(self) |
| 302 } | 302 } |
| 303 } | 303 } |
| 304 | 304 |
| 305 impl<'a, X: Space + Clone> Instance<X, BasicDecomposition> for &'a X { | 305 impl<'a, X: Space> Instance<X, BasicDecomposition> for &'a X { |
| 306 #[inline] | 306 #[inline] |
| 307 fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R | 307 fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R |
| 308 where | 308 where |
| 309 X: 'b, | 309 X: 'b, |
| 310 Self: 'b, | 310 Self: 'b, |
| 320 { | 320 { |
| 321 f(*self) | 321 f(*self) |
| 322 } | 322 } |
| 323 } | 323 } |
| 324 | 324 |
| 325 impl<'a, X: Space + Clone> Instance<X, BasicDecomposition> for &'a mut X { | 325 impl<'a, X: Space> Instance<X, BasicDecomposition> for &'a mut X { |
| 326 #[inline] | 326 #[inline] |
| 327 fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R | 327 fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R |
| 328 where | 328 where |
| 329 X: 'b, | 329 X: 'b, |
| 330 Self: 'b, | 330 Self: 'b, |
| 340 { | 340 { |
| 341 f(*self) | 341 f(*self) |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 impl<'a, X: Space + Clone> Instance<X, BasicDecomposition> for MyCow<'a, X> { | 345 impl<'a, X: Space> Instance<X, BasicDecomposition> for MyCow<'a, X> { |
| 346 #[inline] | 346 #[inline] |
| 347 fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R | 347 fn eval_decompose<'b, R>(self, f: impl FnOnce(MyCow<'b, X>) -> R) -> R |
| 348 where | 348 where |
| 349 X: 'b, | 349 X: 'b, |
| 350 Self: 'b, | 350 Self: 'b, |