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

Method next

atomic-core/src/diff/split.rs:217–254  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

215 type Item = Line<'a>;
216
217 fn next(&mut self) -> Option<Self::Item> {
218 if self.finished {
219 return None;
220 }
221
222 match self.separator.find_in(self.content) {
223 Some(sep_pos) => {
224 // Found separator - return line including separator
225 let sep_len = self.separator.len();
226 let line_end = sep_pos + sep_len;
227 let line = &self.content[..line_end];
228
229 // Advance past this line
230 self.content = &self.content[line_end..];
231 self.position += line_end;
232
233 // Check if this is the last line
234 let is_last = self.content.is_empty();
235 if is_last {
236 self.finished = true;
237 Some(Line::new_last(line))
238 } else {
239 Some(Line::new(line))
240 }
241 }
242 None => {
243 // No more separators - return remaining content as final line
244 self.finished = true;
245 if self.content.is_empty() {
246 None
247 } else {
248 let line = self.content;
249 self.content = &[];
250 Some(Line::new_last(line))
251 }
252 }
253 }
254 }
255
256 fn size_hint(&self) -> (usize, Option<usize>) {
257 if self.finished {

Callers 1

Calls 3

find_inMethod · 0.80
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by 1