| 110 { |
110 { |
| 111 /// Decomposes self according to `decomposer`, and evaluate `f` on the result. |
111 /// Decomposes self according to `decomposer`, and evaluate `f` on the result. |
| 112 /// Consumes self. |
112 /// Consumes self. |
| 113 fn eval_decompose<'b, R>(self, f: impl FnOnce(D::Decomposition<'b>) -> R) -> R |
113 fn eval_decompose<'b, R>(self, f: impl FnOnce(D::Decomposition<'b>) -> R) -> R |
| 114 where |
114 where |
| |
115 R: 'b, |
| 115 X: 'b, |
116 X: 'b, |
| 116 Self: 'b; |
117 Self: 'b; |
| 117 |
118 |
| 118 /// Does a light decomposition of self `decomposer`, and evaluates `f` on the result. |
119 /// Does a light decomposition of self `decomposer`, and evaluates `f` on the result. |
| 119 /// Does not consume self. |
120 /// Does not consume self. |
| 120 fn eval_ref_decompose<'b, R>(&'b self, f: impl FnOnce(D::Reference<'b>) -> R) -> R |
121 fn eval_ref_decompose<'b, 'c, R, F>(&'b self, f: F) -> R |
| 121 where |
122 where |
| 122 X: 'b, |
123 X: 'c, |
| 123 Self: 'b; |
124 Self: 'b, |
| |
125 R: 'b, |
| |
126 F: FnOnce(D::Reference<'c>) -> R; |
| 124 |
127 |
| 125 /// Returns an owned instance of `X`, cloning or converting non-true instances when necessary. |
128 /// Returns an owned instance of `X`, cloning or converting non-true instances when necessary. |
| 126 fn own(self) -> X; |
129 fn own(self) -> X; |
| 127 |
130 |
| 128 // ************** automatically implemented methods below from here ************** |
131 // ************** automatically implemented methods below from here ************** |
| 273 { |
273 { |
| 274 f(self) |
274 f(self) |
| 275 } |
275 } |
| 276 |
276 |
| 277 #[inline] |
277 #[inline] |
| 278 fn eval_ref_decompose<'b, R>(&'b self, f: impl FnOnce(&'b X) -> R) -> R |
278 fn eval_ref_decompose<R, F>(&self, f: F) -> R |
| 279 where |
279 where |
| 280 X: 'b, |
280 F: for<'c> FnOnce(&'c X) -> R, |
| 281 Self: 'b, |
|
| 282 { |
281 { |
| 283 match self { |
282 match self { |
| 284 MyCow::Borrowed(a) => f(a), |
283 MyCow::Borrowed(a) => f(a), |
| 285 MyCow::Owned(b) => f(&b), |
284 MyCow::Owned(b) => f(&b), |
| 286 } |
285 } |