MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / from_lines

Method from_lines

atomic-core/src/record/workflow/recipes/content_hash.rs:57–63  ·  view source on GitHub ↗

Build an index from a slice of line byte-slices. `lines[i].as_ref()` is the byte content of position `i`.

(lines: &[T])

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 3

as_refMethod · 0.80
iterMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected