@@ -3,14 +3,12 @@ use std::marker::PhantomData;
33use std:: str:: FromStr ;
44use thiserror:: Error ;
55
6- #[ derive( Eq , PartialEq , Ord , PartialOrd , Clone , Debug ) ]
6+ #[ derive( Clone , Debug ) ]
77pub struct Tagged < Rep , Tag > ( Rep , PhantomData < Tag > )
88where
99 Rep : Refine < Tag > ;
1010
11- pub trait Refine < Tag > :
12- Eq + PartialEq + Ord + PartialOrd + Clone + Debug
13- {
11+ pub trait Refine < Tag > : Clone + Sized {
1412 type RefineErrorRep : Debug + Display ;
1513 fn refine ( self ) -> Result < Self , Self :: RefineErrorRep > {
1614 Ok ( self )
3937 }
4038}
4139
40+ impl < Rep , Tag > PartialEq for Tagged < Rep , Tag >
41+ where
42+ Rep : Refine < Tag > + PartialEq ,
43+ {
44+ fn eq ( & self , other : & Self ) -> bool {
45+ self . 0 == other. 0
46+ }
47+ }
48+
49+ impl < Rep , Tag > Eq for Tagged < Rep , Tag > where
50+ Rep : Refine < Tag > + Eq
51+ {
52+ }
53+
54+ impl < Rep , Tag > PartialOrd for Tagged < Rep , Tag >
55+ where
56+ Rep : Refine < Tag > + PartialOrd ,
57+ {
58+ fn partial_cmp (
59+ & self ,
60+ other : & Self ,
61+ ) -> Option < std:: cmp:: Ordering > {
62+ self . 0 . partial_cmp ( & other. 0 )
63+ }
64+ }
65+
66+ impl < Rep , Tag > Ord for Tagged < Rep , Tag >
67+ where
68+ Rep : Refine < Tag > + Ord ,
69+ {
70+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
71+ self . 0 . cmp ( & other. 0 )
72+ }
73+ }
74+
4275#[ derive( Debug , Error ) ]
4376pub enum ParseError < Rep , Tag >
4477where
0 commit comments