Skip to content

Commit 8da1604

Browse files
Remove trait implementations on primitive types
Those may interfere with Rust's type inference system and force users to use type annotations even in code that does not use DropItems.
1 parent 762839c commit 8da1604

File tree

2 files changed

+0
-99
lines changed

2 files changed

+0
-99
lines changed

src/itemtraits.rs

-16
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,6 @@ macro_rules! impl_cmp_trait {
144144
}
145145
}
146146

147-
impl<$($lifetime,)? $param $(, $extra_param)?> PartialEq<DropItem<$item_bound>> for $other_type
148-
where $other_type: PartialEq<$param>
149-
{
150-
fn eq(&self, other: &DropItem<$item_bound>) -> bool {
151-
self.eq(other.inner_ref())
152-
}
153-
}
154-
155147
impl<$($lifetime,)? $param $(, $extra_param)?> PartialOrd<$other_type> for DropItem<$item_bound>
156148
where $param: PartialOrd<$other_type>
157149
{
@@ -160,14 +152,6 @@ macro_rules! impl_cmp_trait {
160152
}
161153
}
162154

163-
impl<$($lifetime,)? $param $(, $extra_param)?> PartialOrd<DropItem<$item_bound>> for $other_type
164-
where $other_type: PartialOrd<$param>
165-
{
166-
fn partial_cmp(&self, other: &DropItem<$item_bound>) -> Option<Ordering> {
167-
self.partial_cmp(other.inner_ref())
168-
}
169-
}
170-
171155
impl_cmp_trait! { $($rest)* }
172156
};
173157
}

src/tests.rs

-83
Original file line numberDiff line numberDiff line change
@@ -317,30 +317,6 @@ fn primitive_eq() {
317317
assert_eq!(DropTracker::new().track("abc".to_owned()), "abc");
318318
assert_eq!(DropTracker::new().track([1, 2, 3]), [1, 2, 3][..]);
319319
assert_eq!(DropTracker::new().track(vec![1, 2, 3]), [1, 2, 3][..]);
320-
321-
assert_eq!(123i8, DropTracker::new().track(123i8));
322-
assert_eq!(123i16, DropTracker::new().track(123i16));
323-
assert_eq!(123i32, DropTracker::new().track(123i32));
324-
assert_eq!(123i64, DropTracker::new().track(123i64));
325-
assert_eq!(123i128, DropTracker::new().track(123i128));
326-
327-
assert_eq!(123u8, DropTracker::new().track(123u8));
328-
assert_eq!(123u16, DropTracker::new().track(123u16));
329-
assert_eq!(123u32, DropTracker::new().track(123u32));
330-
assert_eq!(123u64, DropTracker::new().track(123u64));
331-
assert_eq!(123u128, DropTracker::new().track(123u128));
332-
333-
assert_eq!(123f32, DropTracker::new().track_with_value('a', 123f32));
334-
assert_eq!(123f64, DropTracker::new().track_with_value('b', 123f64));
335-
336-
assert_eq!('x', DropTracker::new().track('x'));
337-
assert_eq!(true, DropTracker::new().track(true));
338-
assert_eq!(false, DropTracker::new().track(false));
339-
assert_eq!((), DropTracker::new().track(()));
340-
assert_eq!("abc", DropTracker::new().track("abc"));
341-
assert_eq!("abc", DropTracker::new().track("abc".to_owned()));
342-
assert_eq!([1, 2, 3][..], DropTracker::new().track([1, 2, 3]));
343-
assert_eq!([1, 2, 3][..], DropTracker::new().track(vec![1, 2, 3]));
344320
}
345321

346322
#[test]
@@ -367,29 +343,6 @@ fn primitive_ne() {
367343
assert_ne!(DropTracker::new().track("abc".to_owned()), "def");
368344
assert_ne!(DropTracker::new().track([1, 2, 3]), [4, 5, 6][..]);
369345
assert_ne!(DropTracker::new().track(vec![1, 2, 3]), [4, 5, 6][..]);
370-
371-
assert_ne!(100i8, DropTracker::new().track(123i8));
372-
assert_ne!(100i16, DropTracker::new().track(123i16));
373-
assert_ne!(100i32, DropTracker::new().track(123i32));
374-
assert_ne!(100i64, DropTracker::new().track(123i64));
375-
assert_ne!(100i128, DropTracker::new().track(123i128));
376-
377-
assert_ne!(100u8, DropTracker::new().track(123u8));
378-
assert_ne!(100u16, DropTracker::new().track(123u16));
379-
assert_ne!(100u32, DropTracker::new().track(123u32));
380-
assert_ne!(100u64, DropTracker::new().track(123u64));
381-
assert_ne!(100u128, DropTracker::new().track(123u128));
382-
383-
assert_ne!(100f32, DropTracker::new().track_with_value('a', 123f32));
384-
assert_ne!(100f64, DropTracker::new().track_with_value('b', 123f64));
385-
386-
assert_ne!('y', DropTracker::new().track('x'));
387-
assert_ne!(false, DropTracker::new().track(true));
388-
assert_ne!(true, DropTracker::new().track(false));
389-
assert_ne!("def", DropTracker::new().track("abc"));
390-
assert_ne!("def", DropTracker::new().track("abc".to_owned()));
391-
assert_ne!([4, 5, 6][..], DropTracker::new().track([1, 2, 3]));
392-
assert_ne!([4, 5, 6][..], DropTracker::new().track(vec![1, 2, 3]));
393346
}
394347

395348
#[test]
@@ -411,24 +364,6 @@ fn primitive_lt() {
411364

412365
assert!(DropTracker::new().track('x') < 'y');
413366
assert!(DropTracker::new().track(false) < true);
414-
415-
assert!(100i8 < DropTracker::new().track(123i8));
416-
assert!(100i16 < DropTracker::new().track(123i16));
417-
assert!(100i32 < DropTracker::new().track(123i32));
418-
assert!(100i64 < DropTracker::new().track(123i64));
419-
assert!(100i128 < DropTracker::new().track(123i128));
420-
421-
assert!(100u8 < DropTracker::new().track(123u8));
422-
assert!(100u16 < DropTracker::new().track(123u16));
423-
assert!(100u32 < DropTracker::new().track(123u32));
424-
assert!(100u64 < DropTracker::new().track(123u64));
425-
assert!(100u128 < DropTracker::new().track(123u128));
426-
427-
assert!(100f32 < DropTracker::new().track_with_value('a', 123f32));
428-
assert!(100f64 < DropTracker::new().track_with_value('b', 123f64));
429-
430-
assert!('w' < DropTracker::new().track('x'));
431-
assert!(false < DropTracker::new().track(true));
432367
}
433368

434369
#[test]
@@ -450,22 +385,4 @@ fn primitive_gt() {
450385

451386
assert!(DropTracker::new().track('x') > 'w');
452387
assert!(DropTracker::new().track(true) > false);
453-
454-
assert!(127i8 > DropTracker::new().track(123i8));
455-
assert!(200i16 > DropTracker::new().track(123i16));
456-
assert!(200i32 > DropTracker::new().track(123i32));
457-
assert!(200i64 > DropTracker::new().track(123i64));
458-
assert!(200i128 > DropTracker::new().track(123i128));
459-
460-
assert!(200u8 > DropTracker::new().track(123u8));
461-
assert!(200u16 > DropTracker::new().track(123u16));
462-
assert!(200u32 > DropTracker::new().track(123u32));
463-
assert!(200u64 > DropTracker::new().track(123u64));
464-
assert!(200u128 > DropTracker::new().track(123u128));
465-
466-
assert!(200f32 > DropTracker::new().track_with_value('a', 123f32));
467-
assert!(200f64 > DropTracker::new().track_with_value('b', 123f64));
468-
469-
assert!('y' > DropTracker::new().track('x'));
470-
assert!(true > DropTracker::new().track(false));
471388
}

0 commit comments

Comments
 (0)