Replace MappedWrite
's magic u8 constant with byte string literal
#780
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.)