io
for_each_line

for_each_line

Mojo function 🡭

for_each_line

 
fn for_each_line[func: fn[Bool, Origin[$0]](Span[SIMD[uint8, 1], $1], Int, Int) capturing -> None](path: String, buf_size: Int = 131072)

Call the provided callback on each line. The callback will be given a buffer, and the [start, end) of where the line is in that buffer.

Parameters:

  • func (fn[Bool, Origin[$0]](Span[SIMD[uint8, 1], $1], Int, Int) capturing -> None): The callback to run for each line.

Args:

  • path (String): The file path to open and read.
  • buf_size (Int): The size of the buffer to use.

Raises: