Implement Clone for Buffer and use Arc::make_mut

This commit is contained in:
Jeremy Soller 2023-12-19 15:58:45 -07:00
parent 0a11fb1045
commit 46d60a3723
4 changed files with 21 additions and 10 deletions

View file

@ -237,6 +237,21 @@ pub struct Buffer {
scratch: ShapeBuffer,
}
impl Clone for Buffer {
fn clone(&self) -> Self {
Self {
lines: self.lines.clone(),
metrics: self.metrics,
width: self.width,
height: self.height,
scroll: self.scroll,
redraw: self.redraw,
wrap: self.wrap,
scratch: ShapeBuffer::default(),
}
}
}
impl Buffer {
/// Create an empty [`Buffer`] with the provided [`Metrics`].
/// This is useful for initializing a [`Buffer`] without a [`FontSystem`].