feat(line): implement iterators for Line (#896)

This allows iterating over the `Span`s of a line using `for` loops and
other iterator methods.

- add `iter` and `iter_mut` methods to `Line`
- implement `IntoIterator` for `Line`, `&Line`, and `&mut Line` traits
- update call sites to iterate over `Line` rather than `Line::spans`
This commit is contained in:
Josh McKinney
2024-01-31 08:33:30 -08:00
committed by GitHub
parent 86168aa711
commit 4278b4088d
3 changed files with 130 additions and 4 deletions

View File

@@ -243,7 +243,7 @@ impl Buffer {
pub fn set_line(&mut self, x: u16, y: u16, line: &Line<'_>, width: u16) -> (u16, u16) {
let mut remaining_width = width;
let mut x = x;
for span in &line.spans {
for span in line {
if remaining_width == 0 {
break;
}