Returns an iterator yielding run ends adjusted for the logical slice. Each yielded value is subtracted by the [`logical_offset`] and capped at the [`logical_length`]. [`logical_offset`]: Self::offset [`logical_length`]: Self::len
(&self)
| 197 | /// [`logical_offset`]: Self::offset |
| 198 | /// [`logical_length`]: Self::len |
| 199 | pub fn sliced_values(&self) -> impl Iterator<Item = E> + '_ { |
| 200 | let offset = self.logical_offset; |
| 201 | let len = self.logical_length; |
| 202 | // Doing this roundabout way since the iterator type we return must be |
| 203 | // the same (i.e. cannot use std::iter::empty()) |
| 204 | let physical_slice = if self.is_empty() { |
| 205 | &self.run_ends[0..0] |
| 206 | } else { |
| 207 | let start = self.get_start_physical_index(); |
| 208 | let end = self.get_end_physical_index(); |
| 209 | &self.run_ends[start..=end] |
| 210 | }; |
| 211 | physical_slice.iter().map(move |&val| { |
| 212 | let val = val.as_usize().saturating_sub(offset).min(len); |
| 213 | E::from_usize(val).unwrap() |
| 214 | }) |
| 215 | } |
| 216 | |
| 217 | /// Returns the maximum run-end encoded in the underlying buffer; that is, the |
| 218 | /// last physical run of the buffer. This does not take into account any logical |