src/instance.rs

branch
dev
changeset 134
d65377920b00
parent 133
2b13f8a0c8ba
child 135
087c60877100
equal deleted inserted replaced
133:2b13f8a0c8ba 134:d65377920b00
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 **************
173 { 176 {
174 f(MyCow::Owned(self)) 177 f(MyCow::Owned(self))
175 } 178 }
176 179
177 #[inline] 180 #[inline]
178 fn eval_ref_decompose<'b, R>(&'b self, f: impl FnOnce(&'b X) -> R) -> R 181 fn eval_ref_decompose<R, F>(&self, f: F) -> R
179 where 182 where
180 X: 'b, 183 F: for<'a> FnOnce(&'a X) -> R,
181 Self: 'b,
182 { 184 {
183 f(self) 185 f(self)
184 } 186 }
185 187
186 #[inline] 188 #[inline]
206 { 208 {
207 f(MyCow::Borrowed(self)) 209 f(MyCow::Borrowed(self))
208 } 210 }
209 211
210 #[inline] 212 #[inline]
211 fn eval_ref_decompose<'b, R>(&'b self, f: impl FnOnce(&'b X) -> R) -> R 213 fn eval_ref_decompose<R, F>(&self, f: F) -> R
212 where 214 where
213 X: 'b, 215 F: for<'c> FnOnce(&'c X) -> R,
214 Self: 'b,
215 { 216 {
216 f(*self) 217 f(*self)
217 } 218 }
218 219
219 #[inline] 220 #[inline]
239 { 240 {
240 f(EitherDecomp::Borrowed(self)) 241 f(EitherDecomp::Borrowed(self))
241 } 242 }
242 243
243 #[inline] 244 #[inline]
244 fn eval_ref_decompose<'b, R>(&'b self, f: impl FnOnce(&'b X) -> R) -> R 245 fn eval_ref_decompose<R, F>(&self, f: F) -> R
245 where 246 where
246 X: 'b, 247 F: for<'c> FnOnce(&'c X) -> R,
247 Self: 'b,
248 { 248 {
249 f(*self) 249 f(*self)
250 } 250 }
251 251
252 #[inline] 252 #[inline]
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 }

mercurial