@@ -63,20 +63,21 @@ impl<'self, T> Iterator<&'self T> for ListIterator<'self, T> {
63
63
// corresponding mirrored piece), with, as minimum coordinates, (0,
64
64
// 0). If all is false, only generate half of the possibilities (used
65
65
// to break the symetry of the board).
66
- fn transform ( p : ~[ ( int , int ) ] , all : bool ) -> ~[ ~[ ( int , int ) ] ] {
66
+ fn transform ( piece : ~[ ( int , int ) ] , all : bool ) -> ~[ ~[ ( int , int ) ] ] {
67
67
let mut res =
68
68
// rotations
69
- iterate ( p , |p| p . iter ( ) . map ( |& ( y, x) | ( x + y, -y) ) . collect ( ) )
69
+ iterate ( piece , |rot| rot . iter ( ) . map ( |& ( y, x) | ( x + y, -y) ) . collect ( ) )
70
70
. take ( if all { 6 } else { 3 } )
71
71
// mirror
72
- . flat_map ( |p| {
73
- iterate ( p, |p| p. iter ( ) . map ( |& ( y, x) | ( x, y) ) . collect ( ) ) . take ( 2 )
72
+ . flat_map ( |cur_piece| {
73
+ iterate ( cur_piece, |mir| mir. iter ( ) . map ( |& ( y, x) | ( x, y) ) . collect ( ) )
74
+ . take ( 2 )
74
75
} ) . to_owned_vec ( ) ;
75
76
76
77
// translating to (0, 0) as minimum coordinates.
77
- for p in res. mut_iter ( ) {
78
- let ( dy, dx) = * p . iter ( ) . min_by ( |e| * e) . unwrap ( ) ;
79
- for & ( ref mut y, ref mut x) in p . mut_iter ( ) {
78
+ for cur_piece in res. mut_iter ( ) {
79
+ let ( dy, dx) = * cur_piece . iter ( ) . min_by ( |e| * e) . unwrap ( ) ;
80
+ for & ( ref mut y, ref mut x) in cur_piece . mut_iter ( ) {
80
81
* y -= dy; * x -= dx;
81
82
}
82
83
}
0 commit comments