@@ -301,69 +301,11 @@ macro_rules! getter {
301301
302302#[ cfg( test) ]
303303mod tests {
304- #[ allow( dead_code) ]
305- /// Utilities for testing whether types implement certain traits.
306- ///
307- /// For each trait `Trait` that you want to be able to test, you should
308- /// implement:
309- /// ```ignore
310- /// impl<T: “Trait”> Testable<dyn “Trait”> for T {}
311- /// ```
312- ///
313- /// Then, to test whether a type `Type` implements `Trait`, call:
314- /// ```ignore
315- /// TestTrait::<dyn “Trait”, “Type”>::new().impls_trait()
316- /// ```
317- /// This returns a `bool` indicating whether the trait is implemented.
318- // This relies on auto-deref to distinguish between types that do and don't
319- // implement the trait.
320- mod testtrait {
321- use core:: marker:: PhantomData ;
322-
323- pub struct NonImplTrait < T > {
324- inner : PhantomData < T >
325- }
326-
327- pub struct TestTrait < TraitObj : ?Sized , Type > {
328- non_impl : NonImplTrait < Type > ,
329- phantom : PhantomData < * const TraitObj > ,
330- }
331-
332- pub trait Testable < T : ?Sized > { }
333-
334- impl < TraitObj : ?Sized , Type > TestTrait < TraitObj , Type > {
335- pub fn new ( ) -> Self {
336- TestTrait { non_impl : NonImplTrait { inner : PhantomData } , phantom : PhantomData }
337- }
338- }
339-
340- impl < TraitObj : ?Sized , Type : Testable < TraitObj > > TestTrait < TraitObj , Type > {
341- pub fn impls_trait ( & self ) -> bool {
342- true
343- }
344- }
345-
346- impl < T > NonImplTrait < T > {
347- pub fn impls_trait ( & self ) -> bool {
348- false
349- }
350- }
351-
352- impl < TraitObj : ?Sized , Type > core:: ops:: Deref for TestTrait < TraitObj , Type > {
353- type Target = NonImplTrait < Type > ;
354-
355- fn deref ( & self ) -> & NonImplTrait < Type > {
356- & self . non_impl
357- }
358- }
359- }
360-
361- use testtrait:: { TestTrait , Testable } ;
304+ use crate :: tests:: { TestTrait , Testable } ;
362305
363306 callback ! ( RustTest : Fn ( ) -> ( ) ) ;
364307 callback ! ( NativeTestMut , NativeTest ( ) -> ( ) ) ;
365308
366- impl < T : Send + Sync > Testable < dyn Send + Sync > for T { }
367309 impl < T : RustTest > Testable < dyn RustTest > for T { }
368310 impl < T : NativeTest > Testable < dyn NativeTest > for T { }
369311 impl < T : NativeTestMut > Testable < dyn NativeTestMut > for T { }
0 commit comments