@@ -208,3 +208,84 @@ pub use coresimd::simd;
208
208
#[ unstable( feature = "stdsimd" , issue = "48556" ) ]
209
209
#[ cfg( not( stage0) ) ]
210
210
pub use coresimd:: arch;
211
+
212
+ // FIXME: move to appropriate location
213
+ #[ doc( hidden) ]
214
+ #[ allow( missing_docs) ]
215
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
216
+ pub mod assert_helper {
217
+ use fmt:: { self , Debug , Formatter } ;
218
+
219
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
220
+ #[ allow( missing_debug_implementations) ]
221
+ pub enum Captured < T > {
222
+ Value ( T ) ,
223
+ NotCopy ,
224
+ Unevaluated ,
225
+ }
226
+
227
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
228
+ pub struct DebugFallback < T > {
229
+ value : Captured < T > ,
230
+ alt : & ' static str ,
231
+ }
232
+
233
+ impl < T > DebugFallback < T > {
234
+ #[ inline]
235
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
236
+ pub fn new ( value : Captured < T > , alt : & ' static str ) -> Self {
237
+ DebugFallback { value, alt }
238
+ }
239
+ }
240
+
241
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
242
+ impl < T > Debug for DebugFallback < T > {
243
+ default fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
244
+ f. write_str ( self . alt )
245
+ }
246
+ }
247
+
248
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
249
+ impl < T : Debug > Debug for DebugFallback < T > {
250
+ fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
251
+ match self . value {
252
+ Captured :: Value ( ref value) => Debug :: fmt ( value, f) ,
253
+ Captured :: NotCopy => f. write_str ( self . alt ) ,
254
+ Captured :: Unevaluated => f. write_str ( "(unevaluated)" ) ,
255
+ }
256
+ }
257
+ }
258
+
259
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
260
+ pub trait TryCapture : Sized {
261
+ fn try_capture ( & self , to : & mut Captured < Self > ) -> & Self ;
262
+ }
263
+
264
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
265
+ impl < T > TryCapture for T {
266
+ #[ inline]
267
+ default fn try_capture ( & self , to : & mut Captured < Self > ) -> & Self {
268
+ * to = Captured :: NotCopy ;
269
+ self
270
+ }
271
+ }
272
+
273
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
274
+ impl < T : Copy > TryCapture for T {
275
+ #[ inline]
276
+ fn try_capture ( & self , to : & mut Captured < Self > ) -> & Self {
277
+ * to = Captured :: Value ( * self ) ;
278
+ self
279
+ }
280
+ }
281
+
282
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
283
+ pub struct Unevaluated ;
284
+
285
+ #[ unstable( feature = "generic_assert_internals" , issue = "44838" ) ]
286
+ impl Debug for Unevaluated {
287
+ default fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
288
+ f. write_str ( "(unevaluated)" )
289
+ }
290
+ }
291
+ }
0 commit comments