Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace MappedWrite's magic u8 constant with byte string literal #780

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions libherokubuildpack/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn mapped<W: io::Write, F: (Fn(Vec<u8>) -> Vec<u8>) + Sync + Send + 'static>
MappedWrite::new(w, marker_byte, f)
}

/// Constructs a writer that buffers written data until an ASCII/UTF-8 newline byte (`0x0A`) is
/// Constructs a writer that buffers written data until an ASCII/UTF-8 newline byte (`b'\n'`) is
/// encountered and then applies the given mapping function to the data before passing the result to
/// the wrapped writer.
///
Expand All @@ -25,7 +25,7 @@ pub fn line_mapped<W: io::Write, F: (Fn(Vec<u8>) -> Vec<u8>) + Sync + Send + 'st
w: W,
f: F,
) -> MappedWrite<W> {
mapped(w, NEWLINE_ASCII_BYTE, f)
mapped(w, b'\n', f)
}

/// Constructs a writer that writes to two other writers. Similar to the UNIX `tee` command.
Expand Down Expand Up @@ -155,8 +155,6 @@ impl<A: io::Write, B: io::Write> io::Write for TeeWrite<A, B> {
}
}

const NEWLINE_ASCII_BYTE: u8 = 0x0Au8;

#[cfg(test)]
mod test {
use super::tee;
Expand Down