Skip to content

Commit

Permalink
io: FindByteOutStream to FindByteWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
jayschwa committed Jan 8, 2021
1 parent 1595ce2 commit e72472d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/std/io/change_detection_stream.zig"
"${CMAKE_SOURCE_DIR}/lib/std/io/counting_writer.zig"
"${CMAKE_SOURCE_DIR}/lib/std/io/counting_reader.zig"
"${CMAKE_SOURCE_DIR}/lib/std/io/find_byte_out_stream.zig"
"${CMAKE_SOURCE_DIR}/lib/std/io/find_byte_writer.zig"
"${CMAKE_SOURCE_DIR}/lib/std/io/fixed_buffer_stream.zig"
"${CMAKE_SOURCE_DIR}/lib/std/io/reader.zig"
"${CMAKE_SOURCE_DIR}/lib/std/io/seekable_stream.zig"
Expand Down
8 changes: 6 additions & 2 deletions lib/std/io.zig
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ pub const autoIndentingStream = @import("io/auto_indenting_stream.zig").autoInde
pub const ChangeDetectionStream = @import("io/change_detection_stream.zig").ChangeDetectionStream;
pub const changeDetectionStream = @import("io/change_detection_stream.zig").changeDetectionStream;

pub const FindByteOutStream = @import("io/find_byte_out_stream.zig").FindByteOutStream;
pub const findByteOutStream = @import("io/find_byte_out_stream.zig").findByteOutStream;
pub const FindByteWriter = @import("io/find_byte_writer.zig").FindByteWriter;
pub const findByteWriter = @import("io/find_byte_writer.zig").findByteWriter;
/// Deprecated: use `FindByteWriter`.
pub const FindByteOutStream = FindByteWriter;
/// Deprecated: use `findByteWriter`.
pub const findByteOutStream = findByteWriter;

pub const BufferedAtomicFile = @import("io/buffered_atomic_file.zig").BufferedAtomicFile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const std = @import("../std.zig");
const io = std.io;
const assert = std.debug.assert;

/// An OutStream that returns whether the given character has been written to it.
/// A Writer that returns whether the given character has been written to it.
/// The contents are not written to anything.
pub fn FindByteOutStream(comptime UnderlyingWriter: type) type {
pub fn FindByteWriter(comptime UnderlyingWriter: type) type {
return struct {
const Self = @This();
pub const Error = UnderlyingWriter.Error;
Expand All @@ -37,8 +37,8 @@ pub fn FindByteOutStream(comptime UnderlyingWriter: type) type {
};
}

pub fn findByteOutStream(byte: u8, underlying_writer: anytype) FindByteOutStream(@TypeOf(underlying_writer)) {
return FindByteOutStream(@TypeOf(underlying_writer)){
pub fn findByteWriter(byte: u8, underlying_writer: anytype) FindByteWriter(@TypeOf(underlying_writer)) {
return FindByteWriter(@TypeOf(underlying_writer)){
.underlying_writer = underlying_writer,
.byte = byte,
.byte_found = false,
Expand Down
4 changes: 2 additions & 2 deletions lib/std/zig/render.zig
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ fn renderExpression(
const section_exprs = row_exprs[0..section_end];

// Null stream for counting the printed length of each expression
var line_find_stream = std.io.findByteOutStream('\n', std.io.null_writer);
var line_find_stream = std.io.findByteWriter('\n', std.io.null_writer);
var counting_stream = std.io.countingWriter(line_find_stream.writer());
var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, counting_stream.writer());

Expand Down Expand Up @@ -954,7 +954,7 @@ fn renderExpression(
const expr_outputs_one_line = blk: {
// render field expressions until a LF is found
for (field_inits) |field_init| {
var find_stream = std.io.findByteOutStream('\n', std.io.null_writer);
var find_stream = std.io.findByteWriter('\n', std.io.null_writer);
var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, find_stream.writer());

try renderExpression(allocator, &auto_indenting_stream, tree, field_init, Space.None);
Expand Down

0 comments on commit e72472d

Please sign in to comment.