(I spotted this whilst reviewing #721's usage of MappedWrite - since I think BuildpackOutput::start_stream might also need to start handling newline bytes in the closure passed to line_mapped, and was otherwise thinking we'd need to expose the NEWLINE_ASCII_BYTE constant to build_output, until I realised we didn't really need the magic 0x0Au8 value after all.)
The
NEWLINE_ASCII_BYTE
constant only really existed because it's otherwise not obvious that the0x0Au8
u8 value represents an ASCII newline byte.However, we can replace the
0x0Au8
u8 with a byte string literal ofb'\n'
which is identical in it's value, but much easier to reason about.The byte string literal form is what the Rust stdlib uses in several places: https://github.com/rust-lang/rust/blob/1.76.0/library/core/src/num/mod.rs#L1023 https://github.com/rust-lang/rust/blob/1.76.0/library/core/src/escape.rs#L20 https://github.com/rust-lang/rust/blob/1.76.0/library/std/src/io/buffered/linewritershim.rs#L46
(I spotted this whilst reviewing #721's usage of
MappedWrite
- since I thinkBuildpackOutput::start_stream
might also need to start handling newline bytes in the closure passed toline_mapped
, and was otherwise thinking we'd need to expose theNEWLINE_ASCII_BYTE
constant tobuild_output
, until I realised we didn't really need the magic0x0Au8
value after all.)