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

Method consume

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

Consume one candidate position for `line` — pops the first remaining position from the bucket. Used when matching is 1:1 (each old line claims at most one new line, vice versa). Returns `None` if no candidates left.

(&mut self, line: &[u8])

Source from the content-addressed store, hash-verified

84 ///
85 /// Returns `None` if no candidates left.
86 pub fn consume(&mut self, line: &[u8]) -> Option<usize> {
87 let h = hash_line(line);
88 if let Some(positions) = self.buckets.get_mut(&h) {
89 if !positions.is_empty() {
90 return Some(positions.remove(0));
91 }
92 }
93 None
94 }
95
96 /// Number of distinct hash buckets (not total entries).
97 pub fn bucket_count(&self) -> usize {

Callers 1

build_opsFunction · 0.80

Calls 4

hash_lineFunction · 0.85
get_mutMethod · 0.80
removeMethod · 0.65
is_emptyMethod · 0.45

Tested by

no test coverage detected