Build an index from a slice of line byte-slices. `lines[i].as_ref()` is the byte content of position `i`.
(lines: &[T])
| 55 | /// |
| 56 | /// `lines[i].as_ref()` is the byte content of position `i`. |
| 57 | pub fn from_lines<T: AsRef<[u8]>>(lines: &[T]) -> Self { |
| 58 | let mut idx = Self::new(); |
| 59 | for (i, line) in lines.iter().enumerate() { |
| 60 | idx.insert(line.as_ref(), i); |
| 61 | } |
| 62 | idx |
| 63 | } |
| 64 | |
| 65 | /// Insert a single line at `position`. |
| 66 | pub fn insert(&mut self, line: &[u8], position: usize) { |