Skip to content

Commit ff4f275

Browse files
authored
Improve first() documentation for split iterators
* remove from doc., add explicit info when panic * match convention for assert documentation, avoiding to use panic here
1 parent b4da8ee commit ff4f275

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/std/mem.zig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,9 +2903,10 @@ pub fn WindowIterator(comptime T: type) type {
29032903

29042904
const Self = @This();
29052905

2906-
/// Returns a slice of the first window. This never fails.
2906+
/// Returns a slice of the first window.
29072907
/// Call this only to get the first window and then use `next` to get
29082908
/// all subsequent windows.
2909+
/// Asserts that iteration has not begun.
29092910
pub fn first(self: *Self) []const T {
29102911
assert(self.index.? == 0);
29112912
return self.next().?;
@@ -3037,8 +3038,9 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
30373038

30383039
const Self = @This();
30393040

3040-
/// Returns a slice of the first field. This never fails.
3041+
/// Returns a slice of the first field.
30413042
/// Call this only to get the first field and then use `next` to get all subsequent fields.
3043+
/// Asserts that iteration has not begun.
30423044
pub fn first(self: *Self) []const T {
30433045
assert(self.index.? == 0);
30443046
return self.next().?;
@@ -3101,8 +3103,9 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit
31013103

31023104
const Self = @This();
31033105

3104-
/// Returns a slice of the first field. This never fails.
3106+
/// Returns a slice of the first field.
31053107
/// Call this only to get the first field and then use `next` to get all subsequent fields.
3108+
/// Asserts that iteration has not begun.
31063109
pub fn first(self: *Self) []const T {
31073110
assert(self.index.? == self.buffer.len);
31083111
return self.next().?;

0 commit comments

Comments
 (0)