@@ -49,7 +49,7 @@ struct Edge {
4949    target :  Index , 
5050} 
5151
52- impl < T :  Eq  + Hash >  TransitiveRelation < T >  { 
52+ impl < T :  Eq  + Hash  +  Copy >  TransitiveRelation < T >  { 
5353    pub  fn  is_empty ( & self )  -> bool  { 
5454        self . edges . is_empty ( ) 
5555    } 
@@ -58,8 +58,8 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
5858        self . elements . iter ( ) 
5959    } 
6060
61-     fn  index ( & self ,  a :  & T )  -> Option < Index >  { 
62-         self . elements . get_index_of ( a) . map ( Index ) 
61+     fn  index ( & self ,  a :  T )  -> Option < Index >  { 
62+         self . elements . get_index_of ( & a) . map ( Index ) 
6363    } 
6464
6565    fn  add_index ( & mut  self ,  a :  T )  -> Index  { 
@@ -76,12 +76,12 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
7676/// `None`. 
7777pub  fn  maybe_map < F ,  U > ( & self ,  mut  f :  F )  -> Option < TransitiveRelation < U > > 
7878    where 
79-         F :  FnMut ( & T )  -> Option < U > , 
80-         U :  Clone  + Debug  + Eq  + Hash  + Clone , 
79+         F :  FnMut ( T )  -> Option < U > , 
80+         U :  Clone  + Debug  + Eq  + Hash  + Copy , 
8181    { 
8282        let  mut  result = TransitiveRelation :: default ( ) ; 
8383        for  edge in  & self . edges  { 
84-             result. add ( f ( & self . elements [ edge. source . 0 ] ) ?,  f ( & self . elements [ edge. target . 0 ] ) ?) ; 
84+             result. add ( f ( self . elements [ edge. source . 0 ] ) ?,  f ( self . elements [ edge. target . 0 ] ) ?) ; 
8585        } 
8686        Some ( result) 
8787    } 
@@ -100,7 +100,7 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
100100    } 
101101
102102    /// Checks whether `a < target` (transitively) 
103- pub  fn  contains ( & self ,  a :  & T ,  b :  & T )  -> bool  { 
103+ pub  fn  contains ( & self ,  a :  T ,  b :  T )  -> bool  { 
104104        match  ( self . index ( a) ,  self . index ( b) )  { 
105105            ( Some ( a) ,  Some ( b) )  => self . with_closure ( |closure| closure. contains ( a. 0 ,  b. 0 ) ) , 
106106            ( None ,  _)  | ( _,  None )  => false , 
@@ -113,10 +113,10 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
113113/// Really this probably ought to be `impl Iterator<Item = &T>`, but 
114114/// I'm too lazy to make that work, and -- given the caching 
115115/// strategy -- it'd be a touch tricky anyhow. 
116- pub  fn  reachable_from ( & self ,  a :  & T )  -> Vec < & T >  { 
116+ pub  fn  reachable_from ( & self ,  a :  T )  -> Vec < T >  { 
117117        match  self . index ( a)  { 
118118            Some ( a)  => { 
119-                 self . with_closure ( |closure| closure. iter ( a. 0 ) . map ( |i| & self . elements [ i] ) . collect ( ) ) 
119+                 self . with_closure ( |closure| closure. iter ( a. 0 ) . map ( |i| self . elements [ i] ) . collect ( ) ) 
120120            } 
121121            None  => vec ! [ ] , 
122122        } 
@@ -157,15 +157,15 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
157157/// a -> a1 
158158/// b -> b1 
159159/// ``` 
160- pub  fn  postdom_upper_bound ( & self ,  a :  & T ,  b :  & T )  -> Option < & T >  { 
160+ pub  fn  postdom_upper_bound ( & self ,  a :  T ,  b :  T )  -> Option < T >  { 
161161        let  mubs = self . minimal_upper_bounds ( a,  b) ; 
162162        self . mutual_immediate_postdominator ( mubs) 
163163    } 
164164
165165    /// Viewing the relation as a graph, computes the "mutual 
166166/// immediate postdominator" of a set of points (if one 
167167/// exists). See `postdom_upper_bound` for details. 
168- pub  fn  mutual_immediate_postdominator < ' a > ( & ' a  self ,  mut  mubs :  Vec < & ' a   T > )  -> Option < & ' a   T >  { 
168+ pub  fn  mutual_immediate_postdominator < ' a > ( & ' a  self ,  mut  mubs :  Vec < T > )  -> Option < T >  { 
169169        loop  { 
170170            match  mubs. len ( )  { 
171171                0  => return  None , 
@@ -189,7 +189,7 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
189189///     internal indices). 
190190/// 
191191/// Note that this set can, in principle, have any size. 
192- pub  fn  minimal_upper_bounds ( & self ,  a :  & T ,  b :  & T )  -> Vec < & T >  { 
192+ pub  fn  minimal_upper_bounds ( & self ,  a :  T ,  b :  T )  -> Vec < T >  { 
193193        let  ( Some ( mut  a) ,  Some ( mut  b) )  = ( self . index ( a) ,  self . index ( b) )  else  { 
194194            return  vec ! [ ] ; 
195195        } ; 
@@ -267,7 +267,7 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
267267        lub_indices
268268            . into_iter ( ) 
269269            . rev ( )  // (4) 
270-             . map ( |i| & self . elements [ i] ) 
270+             . map ( |i| self . elements [ i] ) 
271271            . collect ( ) 
272272    } 
273273
@@ -290,7 +290,7 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
290290/// 
291291/// then `parents(a)` returns `[b, c]`. The `postdom_parent` function 
292292/// would further reduce this to just `f`. 
293- pub  fn  parents ( & self ,  a :  & T )  -> Vec < & T >  { 
293+ pub  fn  parents ( & self ,  a :  T )  -> Vec < T >  { 
294294        let  Some ( a)  = self . index ( a)  else  { 
295295            return  vec ! [ ] ; 
296296        } ; 
@@ -314,7 +314,7 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
314314        ancestors
315315            . into_iter ( ) 
316316            . rev ( )  // (4) 
317-             . map ( |i| & self . elements [ i] ) 
317+             . map ( |i| self . elements [ i] ) 
318318            . collect ( ) 
319319    } 
320320
@@ -350,10 +350,10 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
350350
351351    /// Lists all the base edges in the graph: the initial _non-transitive_ set of element 
352352/// relations, which will be later used as the basis for the transitive closure computation. 
353- pub  fn  base_edges ( & self )  -> impl  Iterator < Item  = ( & T ,  & T ) >  { 
353+ pub  fn  base_edges ( & self )  -> impl  Iterator < Item  = ( T ,  T ) >  +  ' _  { 
354354        self . edges 
355355            . iter ( ) 
356-             . map ( move  |edge| ( & self . elements [ edge. source . 0 ] ,  & self . elements [ edge. target . 0 ] ) ) 
356+             . map ( move  |edge| ( self . elements [ edge. source . 0 ] ,  self . elements [ edge. target . 0 ] ) ) 
357357    } 
358358} 
359359
0 commit comments