diff --git a/src/methods/zipping_.rs b/src/methods/zipping_.rs index 9c28ee9..a597381 100644 --- a/src/methods/zipping_.rs +++ b/src/methods/zipping_.rs @@ -297,10 +297,14 @@ declare_zip_items!{ /// This example shows all permutations of argument and return types. /// /// ```rust - /// use typewit::{TypeCmp, TypeEq, TypeNe}; + /// use typewit::{TypeCmp, TypeEq, TypeNe, type_ne}; /// use typewit::methods::zip2; /// - /// with::(TypeEq::NEW, TypeNe::with_any().unwrap(), TypeCmp::with_any()); + /// with::( + /// TypeEq::NEW, + /// type_ne!(u8, bool), + /// TypeCmp::Ne(type_ne!(u16, u32)), + /// ); /// /// const fn with(eq: TypeEq, ne: TypeNe, cmp: TypeCmp) { /// let _: TypeEq<(A, B), (B, A)> = zip2(eq, eq.flip()); @@ -346,10 +350,14 @@ declare_zip_items!{ /// This example shows basic usage. /// /// ```rust - /// use typewit::{TypeCmp, TypeEq, TypeNe, type_eq}; + /// use typewit::{TypeCmp, TypeEq, TypeNe, type_eq, type_ne}; /// use typewit::methods::zip3; /// - /// with::(TypeEq::NEW, TypeNe::with_any().unwrap(), TypeCmp::with_any()); + /// with::( + /// TypeEq::NEW, + /// type_ne!(u8, bool), + /// TypeCmp::Ne(type_ne!(u16, u32)), + /// ); /// /// const fn with(eq: TypeEq, ne: TypeNe, cmp: TypeCmp) { /// let _: TypeEq<(A, B, i64), (B, A, i64)> = zip3(eq, eq.flip(), type_eq::()); @@ -391,10 +399,14 @@ declare_zip_items!{ /// This example shows basic usage. /// /// ```rust - /// use typewit::{TypeCmp, TypeEq, TypeNe, type_eq}; + /// use typewit::{TypeCmp, TypeEq, TypeNe, type_eq, type_ne}; /// use typewit::methods::zip4; /// - /// with::(TypeEq::NEW, TypeNe::with_any().unwrap(), TypeCmp::with_any()); + /// with::( + /// TypeEq::NEW, + /// type_ne!(u8, bool), + /// TypeCmp::Ne(type_ne!(u16, u32)), + /// ); /// /// const fn with(eq: TypeEq, ne: TypeNe, cmp: TypeCmp) { /// let _: TypeEq<(A, u64, B, i64), (B, u64, A, i64)> = @@ -458,11 +470,12 @@ mod with_const_marker { /// methods::in_array, /// const_marker::Usize, /// TypeCmp, TypeEq, TypeNe, + /// type_ne, /// }; /// /// let eq_ty: TypeEq = TypeEq::NEW; - /// let ne_ty: TypeNe = TypeNe::with_any().unwrap(); - /// let cmp_ty: TypeCmp = TypeCmp::with_any(); + /// let ne_ty: TypeNe = type_ne!(i16, u16); + /// let cmp_ty: TypeCmp = TypeCmp::Ne(type_ne!(i16, u16)); /// /// let eq_len: TypeEq, Usize<0>> = TypeEq::NEW; /// let ne_len: TypeNe, Usize<2>> = Usize.equals(Usize).unwrap_ne(); diff --git a/src/type_cmp.rs b/src/type_cmp.rs index acdea98..a2b4876 100644 --- a/src/type_cmp.rs +++ b/src/type_cmp.rs @@ -101,11 +101,16 @@ impl TypeCmp { /// let ne = TypeCmp::::with_any(); /// assert!(matches!(ne, TypeCmp::Ne(_))); /// ``` + #[deprecated = concat!( + "fallout of `https://github.com/rust-lang/rust/issues/97156`,", + "`TypeId::of::() != TypeId::of::()` does not imply `L != R`" + )] pub fn with_any() -> Self where L: Sized + Any, R: Sized + Any, { + #[allow(deprecated)] if let Some(equal) = TypeEq::with_any() { TypeCmp::Eq(equal) } else if let Some(unequal) = TypeNe::with_any() { @@ -179,12 +184,12 @@ impl TypeCmp { /// # Example /// /// ```rust - /// use typewit::{TypeCmp, TypeEq, TypeNe}; + /// use typewit::{TypeCmp, TypeEq, type_ne}; /// - /// let eq: TypeCmp = TypeCmp::with_any(); + /// let eq: TypeCmp = TypeCmp::Eq(TypeEq::NEW); /// assert!(matches!(eq.eq(), Some(TypeEq::{..}))); /// - /// let ne = TypeCmp::::with_any(); + /// let ne = TypeCmp::Ne(type_ne!(u8, i8)); /// assert!(matches!(ne.eq(), None::>)); /// ``` pub const fn eq(self) -> Option> { @@ -199,12 +204,12 @@ impl TypeCmp { /// # Example /// /// ```rust - /// use typewit::{TypeCmp, TypeEq, TypeNe}; + /// use typewit::{TypeCmp, TypeEq, TypeNe, type_ne}; /// - /// let eq: TypeCmp = TypeCmp::with_any(); + /// let eq: TypeCmp = TypeCmp::Eq(TypeEq::NEW); /// assert!(matches!(eq.ne(), None::>)); /// - /// let ne = TypeCmp::::with_any(); + /// let ne = TypeCmp::Ne(type_ne!(u8, i8)); /// assert!(matches!(ne.ne(), Some(TypeNe::{..}))); /// ``` pub const fn ne(self) -> Option> { @@ -259,7 +264,7 @@ impl TypeCmp { /// ```rust /// use typewit::{TypeCmp, TypeEq}; /// - /// let eq: TypeCmp = TypeCmp::with_any(); + /// let eq: TypeCmp = TypeCmp::Eq(TypeEq::NEW); /// assert!(matches!(eq.unwrap_eq(), TypeEq::{..})); /// ``` #[track_caller] @@ -279,9 +284,9 @@ impl TypeCmp { /// # Example /// /// ```rust - /// use typewit::{TypeCmp, TypeNe}; + /// use typewit::{TypeCmp, TypeNe, type_ne}; /// - /// let ne = TypeCmp::::with_any(); + /// let ne = TypeCmp::Ne(type_ne!(u8, i8)); /// assert!(matches!(ne.unwrap_ne(), TypeNe::{..})); /// ``` #[track_caller] diff --git a/src/type_cmp/extra_type_cmp_methods.rs b/src/type_cmp/extra_type_cmp_methods.rs index 875da04..0e9681f 100644 --- a/src/type_cmp/extra_type_cmp_methods.rs +++ b/src/type_cmp/extra_type_cmp_methods.rs @@ -280,10 +280,11 @@ impl TypeCmp { /// use typewit::{ /// const_marker::Usize, /// TypeCmp, TypeEq, TypeNe, + /// type_ne, /// }; /// - /// let cmp_eq_ty: TypeCmp = TypeCmp::with_any(); - /// let cmp_ne_ty: TypeCmp = TypeCmp::with_any(); + /// let cmp_eq_ty: TypeCmp = TypeCmp::Eq(TypeEq::NEW); + /// let cmp_ne_ty: TypeCmp = TypeCmp::Ne(type_ne!(i64, u64)); /// /// let eq_len: TypeEq, Usize<0>> = TypeEq::NEW; /// let ne_len: TypeNe, Usize<2>> = Usize.equals(Usize).unwrap_ne(); diff --git a/src/type_ne_.rs b/src/type_ne_.rs index b5147bd..b16906f 100644 --- a/src/type_ne_.rs +++ b/src/type_ne_.rs @@ -160,13 +160,17 @@ impl TypeNe { /// assert!(TypeNe::::with_any().is_none()); /// /// ``` + #[deprecated = concat!( + "fallout of `https://github.com/rust-lang/rust/issues/97156`,", + "`TypeId::of::() != TypeId::of::()` does not imply `L != R`" + )] pub fn with_any() -> Option where L: Sized + Any, R: Sized + Any, { if TypeId::of::() != TypeId::of::() { - // SAFETY: the two TypeIds compare unequal, so L != R + // SAFETY: unsound for the deprecated reason unsafe { Some(TypeNe::new_unchecked()) } } else { None diff --git a/tests/misc_tests/generic_fns_tests.rs b/tests/misc_tests/generic_fns_tests.rs index 340e1c7..2b042b4 100644 --- a/tests/misc_tests/generic_fns_tests.rs +++ b/tests/misc_tests/generic_fns_tests.rs @@ -3,7 +3,7 @@ use typewit::{ TypeCmp, TypeEq, TypeNe, - type_eq, + type_eq, type_ne, }; use crate::misc_tests::test_utils::assertm; @@ -50,9 +50,9 @@ fn zip2_test() { constness::( TypeEq::NEW, - TypeNe::with_any().unwrap(), - TypeCmp::with_any(), - TypeCmp::with_any(), + type_ne!(u8, bool), + TypeCmp::Eq(TypeEq::NEW), + TypeCmp::Ne(type_ne!(u32, u64)), ); } @@ -101,9 +101,9 @@ fn zip3_test() { constness::( TypeEq::NEW, TypeEq::NEW, - TypeNe::with_any().unwrap(), - TypeCmp::with_any(), - TypeCmp::with_any(), + type_ne!(u8, bool), + TypeCmp::Eq(TypeEq::NEW), + TypeCmp::Ne(type_ne!(u32, u64)), ); } @@ -117,7 +117,11 @@ fn test_zip4() { let _: TypeCmp<(D, A, B, A), (E, B, A, B)> = zip4(cmp, eq, eq.flip(), eq); } - with::(TypeEq::NEW, TypeNe::with_any().unwrap(), TypeCmp::with_any()); + with::( + TypeEq::NEW, + type_ne!(u8, bool), + TypeCmp::Ne(type_ne!(u16, u32)), + ); } #[test] @@ -128,8 +132,8 @@ fn test_in_array() { }; let eq_ty: TypeEq = TypeEq::NEW; - let ne_ty: TypeNe = TypeNe::with_any().unwrap(); - let cmp_ty: TypeCmp = TypeCmp::with_any(); + let ne_ty: TypeNe = type_ne!(i16, u16); + let cmp_ty: TypeCmp = TypeCmp::Ne(type_ne!(i16, u16)); let eq_len: TypeEq, Usize<0>> = TypeEq::NEW; let ne_len: TypeNe, Usize<2>> = Usize.equals(Usize).unwrap_ne(); diff --git a/tests/misc_tests/type_cmp_tests.rs b/tests/misc_tests/type_cmp_tests.rs index 4151f14..f03d95f 100644 --- a/tests/misc_tests/type_cmp_tests.rs +++ b/tests/misc_tests/type_cmp_tests.rs @@ -1,5 +1,5 @@ -use typewit::{TypeCmp, TypeEq, TypeNe}; +use typewit::{TypeCmp, TypeEq, TypeNe, type_ne}; use crate::misc_tests::test_utils::{assertm, assert_type}; @@ -7,6 +7,7 @@ use crate::misc_tests::test_utils::{assertm, assert_type}; mod typecmp_extra_method_tests; +#[allow(deprecated)] #[test] fn test_with_any() { { @@ -23,7 +24,7 @@ fn test_with_any() { #[test] fn test_flip() { - let x = TypeCmp::::with_any().flip(); + let x = TypeCmp::Ne(type_ne!(u8, i8)).flip(); assert_type::<_, TypeCmp>(x); const fn _const_callable(cmp: TypeCmp) { @@ -41,11 +42,11 @@ fn test_join_left() { } { - let x = const_callable::(TypeEq::NEW, TypeCmp::with_any()); + let x = const_callable::(TypeEq::NEW, TypeCmp::Eq(TypeEq::NEW)); assert_type::<_, TypeCmp>(x); } { - let x = const_callable::(TypeEq::NEW, TypeCmp::with_any()); + let x = const_callable::(TypeEq::NEW, TypeCmp::Ne(type_ne!(u8, i8))); assert_type::<_, TypeCmp>(x); } } @@ -60,11 +61,11 @@ fn test_join_right() { } { - let x = const_callable::(TypeCmp::with_any(), TypeEq::NEW); + let x = const_callable::(TypeCmp::Eq(TypeEq::NEW), TypeEq::NEW); assert_type::<_, TypeCmp>(x); } { - let x = const_callable::(TypeCmp::with_any(), TypeEq::NEW); + let x = const_callable::(TypeCmp::Ne(type_ne!(u8, i8)), TypeEq::NEW); assert_type::<_, TypeCmp>(x); } } @@ -77,12 +78,12 @@ fn test_eq() { } { - let x = const_callable(TypeCmp::::with_any()).eq(); + let x = const_callable(TypeCmp::Ne(type_ne!(u8, i8))).eq(); assert_type::<_, Option>>(x); assert!(matches!(x, None{})); } { - let x = const_callable(TypeCmp::::with_any()).eq(); + let x = const_callable(TypeCmp::::Eq(TypeEq::NEW)).eq(); assert_type::<_, Option>>(x); assert!(matches!(x, Some(_))); } @@ -96,12 +97,12 @@ fn test_ne() { } { - let x = const_callable(TypeCmp::::with_any()).ne(); + let x = const_callable(TypeCmp::Ne(type_ne!(u8, i8))).ne(); assert_type::<_, Option>>(x); assert!(matches!(x, Some(_))); } { - let x = const_callable(TypeCmp::::with_any()).ne(); + let x = const_callable(TypeCmp::::Eq(TypeEq::NEW)).ne(); assert_type::<_, Option>>(x); assert!(matches!(x, None{})); } @@ -114,8 +115,8 @@ fn test_is_eq() { cmp } - assert!( const_callable(TypeCmp::::with_any()).is_eq()); - assert!(!const_callable(TypeCmp::::with_any()).is_eq()); + assert!( const_callable(TypeCmp::::Eq(TypeEq::NEW)).is_eq()); + assert!(!const_callable(TypeCmp::Ne(type_ne!(u8, i8))).is_eq()); } #[test] @@ -125,8 +126,8 @@ fn test_is_ne() { cmp } - assert!(!const_callable(TypeCmp::::with_any()).is_ne()); - assert!( const_callable(TypeCmp::::with_any()).is_ne()); + assert!(!const_callable(TypeCmp::::Eq(TypeEq::NEW)).is_ne()); + assert!( const_callable(TypeCmp::Ne(type_ne!(u8, i8))).is_ne()); } #[test] @@ -136,14 +137,14 @@ fn test_unwrap_eq() { cmp } - let x = const_callable(TypeCmp::::with_any()).unwrap_eq(); + let x = const_callable(TypeCmp::::Eq(TypeEq::NEW)).unwrap_eq(); assert_type::<_, TypeEq>(x); } #[test] #[should_panic] fn test_unwrap_eq_panicking() { - TypeCmp::::with_any().unwrap_eq(); + TypeCmp::Ne(type_ne!(u8, i8)).unwrap_eq(); } @@ -154,14 +155,14 @@ fn test_unwrap_ne() { cmp } - let x = const_callable(TypeCmp::::with_any()).unwrap_ne(); + let x = const_callable(TypeCmp::Ne(type_ne!(u8, i8))).unwrap_ne(); assert_type::<_, TypeNe>(x); } #[test] #[should_panic] fn test_unwrap_ne_panicking() { - TypeCmp::::with_any().unwrap_ne(); + TypeCmp::::Eq(TypeEq::NEW).unwrap_ne(); } #[cfg(feature = "rust_1_61")] @@ -193,9 +194,9 @@ fn test_zip_method() { constness::( TypeEq::NEW, - TypeNe::with_any().unwrap(), - TypeCmp::with_any(), - TypeCmp::with_any(), + type_ne!(u8, bool), + TypeCmp::Eq(TypeEq::NEW), + TypeCmp::Ne(type_ne!(u32, u64)), ); } @@ -242,9 +243,9 @@ fn test_zip3_method() { constness::( TypeEq::NEW, TypeEq::NEW, - TypeNe::with_any().unwrap(), - TypeCmp::with_any(), - TypeCmp::with_any(), + type_ne!(u8, bool), + TypeCmp::Eq(TypeEq::NEW), + TypeCmp::Ne(type_ne!(u32, u64)), ); } @@ -281,9 +282,9 @@ fn test_zip4_method() { with::( TypeEq::NEW, - TypeNe::with_any().unwrap(), - TypeCmp::with_any(), - TypeCmp::with_any(), + type_ne!(u8, bool), + TypeCmp::Eq(TypeEq::NEW), + TypeCmp::Ne(type_ne!(u32, u64)), ); } @@ -295,8 +296,8 @@ fn test_in_array_method() { TypeCmp, TypeEq, TypeNe, }; - let cmp_eq_ty: TypeCmp = TypeCmp::with_any(); - let cmp_ne_ty: TypeCmp = TypeCmp::with_any(); + let cmp_eq_ty: TypeCmp = TypeCmp::Eq(TypeEq::NEW); + let cmp_ne_ty: TypeCmp = TypeCmp::Ne(type_ne!(i64, u64)); let eq_len: TypeEq, Usize<0>> = TypeEq::NEW; let ne_len: TypeNe, Usize<2>> = Usize.equals(Usize).unwrap_ne(); diff --git a/tests/misc_tests/type_cmp_tests/typecmp_extra_method_tests.rs b/tests/misc_tests/type_cmp_tests/typecmp_extra_method_tests.rs index d6875f0..738c16f 100644 --- a/tests/misc_tests/type_cmp_tests/typecmp_extra_method_tests.rs +++ b/tests/misc_tests/type_cmp_tests/typecmp_extra_method_tests.rs @@ -1,6 +1,7 @@ use typewit::{ type_fn::GRef, - TypeCmp, + TypeCmp, TypeEq, + type_ne, }; use crate::misc_tests::test_utils::assert_type; @@ -29,11 +30,11 @@ fn test_map() { } { - let x = constness(TypeCmp::::with_any()).map(GRef::NEW); + let x = constness(TypeCmp::::Eq(TypeEq::NEW)).map(GRef::NEW); assert_type::<_, TypeCmp<&u8, &u8>>(x); } { - let x = constness(TypeCmp::::with_any()).map(GRef::NEW); + let x = constness(TypeCmp::Ne(type_ne!(u8, i8))).map(GRef::NEW); assert_type::<_, TypeCmp<&u8, &i8>>(x); } } @@ -46,11 +47,11 @@ fn test_project() { } { - let x = constness(TypeCmp::::with_any()).project::(); + let x = constness(TypeCmp::::Eq(TypeEq::NEW)).project::(); assert_type::<_, TypeCmp, Foo>>(x); } { - let x = constness(TypeCmp::::with_any()).project::(); + let x = constness(TypeCmp::Ne(type_ne!(u8, i8))).project::(); assert_type::<_, TypeCmp, Foo>>(x); } } @@ -65,11 +66,11 @@ fn test_unmap() { } { - let x = constness(TypeCmp::, Bar>::with_any()).unmap(BarFn); + let x = constness(TypeCmp::, Bar>::Eq(TypeEq::NEW)).unmap(BarFn); assert_type::<_, TypeCmp>(x); } { - let x = constness(TypeCmp::, Bar>::with_any()).unmap(BarFn); + let x = constness(TypeCmp::Ne(type_ne!(Bar, Bar))).unmap(BarFn); assert_type::<_, TypeCmp>(x); } } @@ -84,11 +85,11 @@ fn test_unproject() { } { - let x = constness(TypeCmp::<&u8, &u8>::with_any()).unproject::>(); + let x = constness(TypeCmp::<&u8, &u8>::Eq(TypeEq::NEW)).unproject::>(); assert_type::<_, TypeCmp>(x); } { - let x = constness(TypeCmp::<&u8, &i8>::with_any()).unproject::>(); + let x = constness(TypeCmp::Ne(type_ne!(<'a> &'a u8, &'a i8))).unproject::>(); assert_type::<_, TypeCmp>(x); } } @@ -101,11 +102,11 @@ fn test_in_ref() { } { - let x = constness(TypeCmp::::with_any()).in_ref(); + let x = constness(TypeCmp::::Eq(TypeEq::NEW)).in_ref(); assert_type::<_, TypeCmp<&u8, &u8>>(x); } { - let x = constness(TypeCmp::::with_any()).in_ref(); + let x = constness(TypeCmp::Ne(type_ne!(u8, i8))).in_ref(); assert_type::<_, TypeCmp<&u8, &i8>>(x); } } @@ -119,11 +120,11 @@ fn test_in_mut() { } { - let x = TypeCmp::::with_any().in_mut(); + let x = TypeCmp::::Eq(TypeEq::NEW).in_mut(); assert_type::<_, TypeCmp<&mut u8, &mut u8>>(x); } { - let x = TypeCmp::::with_any().in_mut(); + let x = TypeCmp::Ne(type_ne!(u8, i8)).in_mut(); assert_type::<_, TypeCmp<&mut u8, &mut i8>>(x); } } @@ -137,11 +138,11 @@ fn test_in_box() { } { - let x = constness(TypeCmp::::with_any()).in_box(); + let x = constness(TypeCmp::::Eq(TypeEq::NEW)).in_box(); assert_type::<_, TypeCmp, Box>>(x); } { - let x = constness(TypeCmp::::with_any()).in_box(); + let x = constness(TypeCmp::Ne(type_ne!(u8, i8))).in_box(); assert_type::<_, TypeCmp, Box>>(x); } } \ No newline at end of file diff --git a/tests/misc_tests/type_ne_tests.rs b/tests/misc_tests/type_ne_tests.rs index 6d3bd9c..da933ad 100644 --- a/tests/misc_tests/type_ne_tests.rs +++ b/tests/misc_tests/type_ne_tests.rs @@ -1,16 +1,12 @@ -use typewit::{TypeCmp, TypeEq, TypeNe}; +use typewit::{TypeCmp, TypeEq, TypeNe, type_ne}; use crate::misc_tests::test_utils::{assert_type, assert_type_ne}; mod typene_extra_method_tests; -#[track_caller] -fn typene() -> TypeNe { - TypeNe::with_any().unwrap() -} - +#[allow(deprecated)] #[test] fn with_any_test() { assert!(TypeNe::::with_any().is_none()); @@ -25,7 +21,7 @@ fn flip_method() { assert_type_ne(te.flip(), te); let _ = |te: TypeNe| -> TypeNe { te.flip() }; } - flipper(typene::()); + flipper(type_ne!(u8, u16)); } #[test] @@ -34,7 +30,7 @@ fn join_left_method() { let _: TypeNe = tea.join_left(teb); assert_type::<_, TypeNe>(tea.join_left(teb)); } - joiner(typene::(), TypeEq::NEW); + joiner(type_ne!(u8, u16), TypeEq::NEW); } #[test] @@ -43,7 +39,7 @@ fn join_right_method() { let _: TypeNe = tea.join_right(teb); assert_type::<_, TypeNe>(tea.join_right(teb)); } - joiner(typene::(), TypeEq::NEW); + joiner(type_ne!(u8, u16), TypeEq::NEW); } @@ -58,7 +54,7 @@ fn zip_test() { left.zip(right) } - let _ = do_zip(typene::(), typene::()); + let _ = do_zip(type_ne!(u16, u8), type_ne!(u16, &'static str)); } { @@ -69,7 +65,7 @@ fn zip_test() { left.zip(right) } - let _ = do_zip(typene::(), TypeEq::NEW); + let _ = do_zip(type_ne!(u16, u8), TypeEq::NEW); } { @@ -80,8 +76,8 @@ fn zip_test() { left.zip(right) } - let _ = do_zip(typene::(), TypeCmp::Ne(typene::())); - let _ = do_zip(typene::(), TypeCmp::Eq(TypeEq::NEW)); + let _ = do_zip(type_ne!(u16, u8), TypeCmp::Ne(type_ne!(u16, &'static str))); + let _ = do_zip(type_ne!(u16, u8), TypeCmp::Eq(TypeEq::NEW)); } } @@ -97,7 +93,7 @@ fn zip3_test() { a.zip3(b, c) } - let _ = do_zip(typene::(), typene::(), typene::()); + let _ = do_zip(type_ne!(u16, u8), type_ne!(u16, &'static str), type_ne!(u16, Vec)); } { @@ -109,7 +105,7 @@ fn zip3_test() { a.zip3(b, c) } - let _ = do_zip(typene::(), TypeEq::NEW, typene::()); + let _ = do_zip(type_ne!(u16, u8), TypeEq::NEW, type_ne!(u16, Vec)); } { @@ -121,7 +117,7 @@ fn zip3_test() { a.zip3(b, c) } - let _ = do_zip(typene::(), typene::(), TypeEq::NEW); + let _ = do_zip(type_ne!(u16, u8), type_ne!(u16, &'static str), TypeEq::NEW); } { @@ -133,8 +129,16 @@ fn zip3_test() { a.zip3(b, c) } - let _ = do_zip(typene::(), typene::(), TypeCmp::Ne(typene::())); - let _ = do_zip(typene::(), typene::(), TypeCmp::Eq(TypeEq::NEW)); + let _ = do_zip( + type_ne!(u16, u8), + type_ne!(u16, &'static str), + TypeCmp::Ne(type_ne!(u16, Vec)), + ); + let _ = do_zip( + type_ne!(u16, u8), + type_ne!(u16, &'static str), + TypeCmp::Eq(TypeEq::NEW), + ); } } @@ -151,7 +155,12 @@ fn zip4_test() { a.zip4(b, c, d) } - let _ = do_zip(typene::(), typene::(), typene::(), typene::()); + let _ = do_zip( + type_ne!(u16, u8), + type_ne!(u16, &'static str), + type_ne!(u16, Vec), + type_ne!(u16, [u8; 2]), + ); } { @@ -164,7 +173,12 @@ fn zip4_test() { a.zip4(b, c, d) } - let _ = do_zip(typene::(), TypeEq::NEW, typene::(), typene::()); + let _ = do_zip( + type_ne!(u16, u8), + TypeEq::NEW, + type_ne!(u16, Vec), + type_ne!(u16, [u8; 2]), + ); } { @@ -178,17 +192,17 @@ fn zip4_test() { } let _ = do_zip( - typene::(), + type_ne!(u16, u8), TypeCmp::Eq(TypeEq::NEW), - typene::(), - typene::(), + type_ne!(u16, Vec), + type_ne!(u16, [u8; 2]), ); let _ = do_zip( - typene::(), - TypeCmp::Ne(typene::()), - typene::(), - typene::(), + type_ne!(u16, u8), + TypeCmp::Ne(type_ne!(u16, &'static str)), + type_ne!(u16, Vec), + type_ne!(u16, [u8; 2]), ); } @@ -202,7 +216,12 @@ fn zip4_test() { a.zip4(b, c, d) } - let _ = do_zip(typene::(), typene::(), TypeEq::NEW, typene::()); + let _ = do_zip( + type_ne!(u16, u8), + type_ne!(u16, &'static str), + TypeEq::NEW, + type_ne!(u16, [u8; 2]), + ); } { @@ -215,7 +234,12 @@ fn zip4_test() { a.zip4(b, c, d) } - let _ = do_zip(typene::(), typene::(), typene::(), TypeEq::NEW); + let _ = do_zip( + type_ne!(u16, u8), + type_ne!(u16, &'static str), + type_ne!(u16, Vec), + TypeEq::NEW, + ); } } diff --git a/tests/misc_tests/type_ne_tests/typene_extra_method_tests.rs b/tests/misc_tests/type_ne_tests/typene_extra_method_tests.rs index 1b85e6d..45d8e2d 100644 --- a/tests/misc_tests/type_ne_tests/typene_extra_method_tests.rs +++ b/tests/misc_tests/type_ne_tests/typene_extra_method_tests.rs @@ -1,18 +1,15 @@ use typewit::{ type_fn::{GRef, GRefMut, TypeFn}, TypeNe, + type_ne, }; use crate::misc_tests::test_utils::{assert_type, assert_type_eq}; -use super::typene; - - - #[test] fn map_test() { - assert_type::<_, TypeNe<&u8, &u16>>(typene::().map(GRef::NEW)); - assert_type::<_, TypeNe<&mut u8, &mut u16>>(typene::().map(GRefMut::NEW)); + assert_type::<_, TypeNe<&u8, &u16>>(type_ne!(u8, u16).map(GRef::NEW)); + assert_type::<_, TypeNe<&mut u8, &mut u16>>(type_ne!(u8, u16).map(GRefMut::NEW)); } #[test] @@ -29,21 +26,21 @@ fn project_test() { } - assert_type::<_, TypeNe<&u8, &u16>>(typene::().project::>()); - assert_type::<_, TypeNe<&mut u8, &mut u16>>(typene::().project::>()); - assert_type::<_, TypeNe, Foo>>(typene::().project::()); + assert_type::<_, TypeNe<&u8, &u16>>(type_ne!(u8, u16).project::>()); + assert_type::<_, TypeNe<&mut u8, &mut u16>>(type_ne!(u8, u16).project::>()); + assert_type::<_, TypeNe, Foo>>(type_ne!(u8, u16).project::()); } #[test] fn unmap_test() { { - let ne: TypeNe<&u8, &u16> = typene::().map(GRef::NEW); - assert_type_eq(ne.unmap(GRef::NEW), typene::()); + let ne: TypeNe<&u8, &u16> = type_ne!(u8, u16).map(GRef::NEW); + assert_type_eq(ne.unmap(GRef::NEW), type_ne!(u8, u16)); } { - let ne: TypeNe<&mut u8, &mut u16> = typene::().map(GRefMut::NEW); - assert_type_eq(ne.unmap(GRefMut::NEW), typene::()); + let ne: TypeNe<&mut u8, &mut u16> = type_ne!(u8, u16).map(GRefMut::NEW); + assert_type_eq(ne.unmap(GRefMut::NEW), type_ne!(u8, u16)); } } @@ -62,14 +59,14 @@ fn unproject_test() { } { - let ne: TypeNe<&u8, &u16> = typene::().project::>(); - assert_type_eq(ne.unproject::>(), typene::()); + let ne: TypeNe<&u8, &u16> = type_ne!(u8, u16).project::>(); + assert_type_eq(ne.unproject::>(), type_ne!(u8, u16)); } { - let ne: TypeNe<&mut u8, &mut u16> = typene::().project::>(); - assert_type_eq(ne.unproject::>(), typene::()); + let ne: TypeNe<&mut u8, &mut u16> = type_ne!(u8, u16).project::>(); + assert_type_eq(ne.unproject::>(), type_ne!(u8, u16)); } - assert_eq!(typene::, Foo>().unproject::(), typene::()); + assert_eq!(type_ne!(Foo, Foo).unproject::(), type_ne!(u8, u16)); } @@ -77,12 +74,12 @@ fn unproject_test() { #[test] fn in_ref_test() { - assert_type::<_, TypeNe<&u8, &u16>>(typene::().in_ref()); + assert_type::<_, TypeNe<&u8, &u16>>(type_ne!(u8, u16).in_ref()); } #[test] fn in_mut_test() { - assert_type::<_, TypeNe<&mut u8, &mut u16>>(typene::().in_mut()); + assert_type::<_, TypeNe<&mut u8, &mut u16>>(type_ne!(u8, u16).in_mut()); #[cfg(feature = "mut_refs")] { @@ -95,7 +92,7 @@ fn in_mut_test() { #[cfg(feature = "alloc")] #[test] fn in_box_test() { - assert_type::<_, TypeNe, Box>>(typene::().in_box()); + assert_type::<_, TypeNe, Box>>(type_ne!(u8, u16).in_box()); } @@ -105,20 +102,20 @@ fn test_in_array() { use typewit::const_marker::Usize; { - let ne = typene::().in_array(Usize::<1>.equals(Usize::<2>)); + let ne = type_ne!(u8, u16).in_array(Usize::<1>.equals(Usize::<2>)); assert_type::<_, TypeNe<[u8; 1], [u16; 2]>>(ne); } { - let ne = typene::().in_array(Usize::<1>.equals(Usize::<2>).unwrap_ne()); + let ne = type_ne!(u8, u16).in_array(Usize::<1>.equals(Usize::<2>).unwrap_ne()); assert_type::<_, TypeNe<[u8; 1], [u16; 2]>>(ne); } { - let ne = typene::().in_array(Usize::<1>.equals(Usize::<1>).unwrap_eq()); + let ne = type_ne!(u8, u16).in_array(Usize::<1>.equals(Usize::<1>).unwrap_eq()); assert_type::<_, TypeNe<[u8; 1], [u16; 1]>>(ne); } { - let ne = typene::().in_array(Usize::<1>.equals(Usize::<1>)); + let ne = type_ne!(u8, u16).in_array(Usize::<1>.equals(Usize::<1>)); assert_type::<_, TypeNe<[u8; 1], [u16; 1]>>(ne); } }