Flush all remaining buffered cursors to the delegate sink in source order. This is typically called when no more cursors will be added.
(&mut self)
| 31 | /// Flush all remaining buffered cursors to the delegate sink in source order. |
| 32 | /// This is typically called when no more cursors will be added. |
| 33 | pub fn flush(&mut self) { |
| 34 | self.buffer.sort_by_key(|cursor| cursor.span().start()); |
| 35 | for cursor in self.buffer.iter() { |
| 36 | self.sink.append(*cursor); |
| 37 | } |
| 38 | if let Some(last_cursor) = self.buffer.last() { |
| 39 | self.committed_position = last_cursor.end_offset(); |
| 40 | } |
| 41 | self.buffer.clear(); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | impl<'a, S: CursorSink> CursorSink for CursorOrderedSink<'a, S> { |