File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ pub struct History {
54
54
}
55
55
56
56
/// A single point in history. See [History] for more information.
57
- #[ derive( Debug ) ]
57
+ #[ derive( Debug , Clone ) ]
58
58
struct Revision {
59
59
parent : usize ,
60
60
last_child : Option < NonZeroUsize > ,
@@ -126,15 +126,13 @@ impl History {
126
126
return None ;
127
127
}
128
128
129
- let mut transaction = self . revisions [ revision] . transaction . clone ( ) ;
130
-
131
129
// The bounds are checked in the if condition above:
132
- // `revision + 1 ` is known to be `<= self.current`.
133
- for revision in & self . revisions [ revision + 1 ..self . current ] {
134
- transaction = transaction . compose ( revision . transaction . clone ( ) ) ;
135
- }
136
-
137
- Some ( transaction)
130
+ // `revision` is known to be `< self.current`.
131
+ self . revisions [ revision..self . current ]
132
+ . iter ( )
133
+ . map ( |revision| & revision . transaction )
134
+ . cloned ( )
135
+ . reduce ( |acc , transaction| acc . compose ( transaction ) )
138
136
}
139
137
140
138
/// Undo the last edit.
You can’t perform that action at this time.
0 commit comments