[][src]Function line_wrap::line_wrap

pub fn line_wrap<L: LineEnding>(
    buf: &mut [u8],
    input_len: usize,
    line_len: usize,
    line_ending: &L
) -> usize

Insert line endings into the input.

Endings are inserted after each complete line, except the last line, even if the last line takes up the full line width.

  • buf must be large enough to handle the increased size after endings are inserted. In other words, buf.len() >= input_len / line_len * line_ending.len().
  • input_len is the length of the unwrapped in buf.
  • line_len is the desired line width without line ending characters.

Returns the number of line ending bytes added.

Panics

  • When line_ending.len() == 0
  • When buf is too small to contain the original input and its new line endings