zig/lib/std/io
Isaac Freund 23b7d28896 std: restrict mem.span() and mem.len() to sentinel terminated pointers
These functions are currently footgunny when working with pointers to
arrays and slices. They just return the stated length of the array/slice
without iterating and looking for the first sentinel, even if the
array/slice is a sentinel terminated type.

From looking at the quite small list of places in the standard
library/compiler that this change breaks existing code, the new code
looks to be more readable in all cases.

The usage of std.mem.span/len was totally unneeded in most of the cases
affected by this breaking change.

We could remove these functions entirely in favor of other existing
functions in std.mem such as std.mem.sliceTo(), but that would be a
somewhat nasty breaking change as std.mem.span() is very widely used for
converting sentinel terminated pointers to slices. It is however not at
all widely used for anything else.

Therefore I think it is better to break these few non-standard and
potentially incorrect usages of these functions now and at some later
time, if deemed worthwhile, finally remove these functions.

If we wait for at least a full release cycle so that everyone adapts to
this change first, updating for the removal could be a simple find and
replace without needing to worry about the semantics.
2023-01-29 15:07:06 -05:00
..
bit_reader.zig Sema: add error for non-comptime param in comptime func 2022-08-27 11:17:48 +03:00
bit_writer.zig Sema: add error for non-comptime param in comptime func 2022-08-27 11:17:48 +03:00
buffered_atomic_file.zig allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
buffered_reader.zig expose std.io.bufferedReaderSize 2023-01-11 15:39:48 -08:00
buffered_writer.zig Stop using LinearFifo in BufferedWriter 2022-01-23 14:41:15 -05:00
c_writer.zig std: update test cases to reflect new packed struct semantics 2022-07-12 18:38:11 -07:00
change_detection_stream.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
counting_reader.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
counting_writer.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
find_byte_writer.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
fixed_buffer_stream.zig std: restrict mem.span() and mem.len() to sentinel terminated pointers 2023-01-29 15:07:06 -05:00
limited_reader.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
multi_writer.zig std.builtin: rename Type.UnionField and Type.StructField's field_type to type 2022-12-17 14:11:33 +01:00
peek_stream.zig allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
reader.zig Find system-installed root SSL certificates on macOS (#14325) 2023-01-16 22:34:04 +00:00
seekable_stream.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
stream_source.zig Sema: add missing set_union_tag 2022-06-12 19:17:41 +03:00
test.zig std.rand: Refactor Random interface 2021-10-27 16:07:48 -04:00
writer.zig deprecated TypeInfo in favor of Type 2022-03-08 20:38:12 +02:00