diff --git a/src/attrs.rs b/src/attrs.rs index 1b17eed..046300c 100644 --- a/src/attrs.rs +++ b/src/attrs.rs @@ -306,7 +306,12 @@ impl AttrsList { /// Get the current attribute spans pub fn spans(&self) -> Vec<(&Range, &AttrsOwned)> { - self.spans.iter().collect() + self.spans_iter().collect() + } + + /// Get an iterator over the current attribute spans + pub fn spans_iter(&self) -> impl Iterator, &AttrsOwned)> + '_ { + self.spans.iter() } /// Clear the current attribute spans diff --git a/src/buffer_line.rs b/src/buffer_line.rs index 9eba6c7..4f1a195 100644 --- a/src/buffer_line.rs +++ b/src/buffer_line.rs @@ -144,7 +144,7 @@ impl BufferLine { .add_span(len..len + other.text().len(), other.attrs_list.defaults()); } - for (other_range, attrs) in other.attrs_list.spans() { + for (other_range, attrs) in other.attrs_list.spans_iter() { // Add previous attrs spans let range = other_range.start + len..other_range.end + len; self.attrs_list.add_span(range, attrs.as_attrs());