| ... | @@ -1910,7 +1910,7 @@ test "byteSwapAllFields" { | ... | @@ -1910,7 +1910,7 @@ test "byteSwapAllFields" { |
| 1910 | }, s); | 1910 | }, s); |
| 1911 | } | 1911 | } |
| 1912 | | 1912 | |
| 1913 | /// Deprecated: use `tokenizeAny`, `tokenizeFull`, or `tokenizeScalar` | 1913 | /// Deprecated: use `tokenizeAny`, `tokenizeSequence`, or `tokenizeScalar` |
| 1914 | pub const tokenize = tokenizeAny; | 1914 | pub const tokenize = tokenizeAny; |
| 1915 | | 1915 | |
| 1916 | /// Returns an iterator that iterates over the slices of `buffer` that are not | 1916 | /// Returns an iterator that iterates over the slices of `buffer` that are not |
| ... | @@ -1923,9 +1923,9 @@ pub const tokenize = tokenizeAny; | ... | @@ -1923,9 +1923,9 @@ pub const tokenize = tokenizeAny; |
| 1923 | /// If none of `delimiters` exist in buffer, | 1923 | /// If none of `delimiters` exist in buffer, |
| 1924 | /// the iterator will return `buffer`, null, in that order. | 1924 | /// the iterator will return `buffer`, null, in that order. |
| 1925 | /// | 1925 | /// |
| 1926 | /// See also: `tokenizeFull`, `tokenizeScalar`, | 1926 | /// See also: `tokenizeSequence`, `tokenizeScalar`, |
| 1927 | /// `splitFull`,`splitAny`, `splitScalar`, | 1927 | /// `splitSequence`,`splitAny`, `splitScalar`, |
| 1928 | /// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar` | 1928 | /// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar` |
| 1929 | pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) TokenIterator(T, .any) { | 1929 | pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) TokenIterator(T, .any) { |
| 1930 | return .{ | 1930 | return .{ |
| 1931 | .index = 0, | 1931 | .index = 0, |
| ... | @@ -1937,7 +1937,7 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T | ... | @@ -1937,7 +1937,7 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T |
| 1937 | /// Returns an iterator that iterates over the slices of `buffer` that are not | 1937 | /// Returns an iterator that iterates over the slices of `buffer` that are not |
| 1938 | /// the sequence in `delimiter`. | 1938 | /// the sequence in `delimiter`. |
| 1939 | /// | 1939 | /// |
| 1940 | /// `tokenizeFull(u8, "<>abc><def<><>ghi", "<>")` will return slices | 1940 | /// `tokenizeSequence(u8, "<>abc><def<><>ghi", "<>")` will return slices |
| 1941 | /// for "abc><def", "ghi", null, in that order. | 1941 | /// for "abc><def", "ghi", null, in that order. |
| 1942 | /// | 1942 | /// |
| 1943 | /// If `buffer` is empty, the iterator will return null. | 1943 | /// If `buffer` is empty, the iterator will return null. |
| ... | @@ -1946,9 +1946,9 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T | ... | @@ -1946,9 +1946,9 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T |
| 1946 | /// The delimiter length must not be zero. | 1946 | /// The delimiter length must not be zero. |
| 1947 | /// | 1947 | /// |
| 1948 | /// See also: `tokenizeAny`, `tokenizeScalar`, | 1948 | /// See also: `tokenizeAny`, `tokenizeScalar`, |
| 1949 | /// `splitFull`,`splitAny`, and `splitScalar` | 1949 | /// `splitSequence`,`splitAny`, and `splitScalar` |
| 1950 | /// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar` | 1950 | /// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar` |
| 1951 | pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .full) { | 1951 | pub fn tokenizeSequence(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .sequence) { |
| 1952 | assert(delimiter.len != 0); | 1952 | assert(delimiter.len != 0); |
| 1953 | return .{ | 1953 | return .{ |
| 1954 | .index = 0, | 1954 | .index = 0, |
| ... | @@ -1967,9 +1967,9 @@ pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) T | ... | @@ -1967,9 +1967,9 @@ pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) T |
| 1967 | /// If `delimiter` does not exist in buffer, | 1967 | /// If `delimiter` does not exist in buffer, |
| 1968 | /// the iterator will return `buffer`, null, in that order. | 1968 | /// the iterator will return `buffer`, null, in that order. |
| 1969 | /// | 1969 | /// |
| 1970 | /// See also: `tokenizeAny`, `tokenizeFull`, | 1970 | /// See also: `tokenizeAny`, `tokenizeSequence`, |
| 1971 | /// `splitFull`,`splitAny`, and `splitScalar` | 1971 | /// `splitSequence`,`splitAny`, and `splitScalar` |
| 1972 | /// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar` | 1972 | /// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar` |
| 1973 | pub fn tokenizeScalar(comptime T: type, buffer: []const T, delimiter: T) TokenIterator(T, .scalar) { | 1973 | pub fn tokenizeScalar(comptime T: type, buffer: []const T, delimiter: T) TokenIterator(T, .scalar) { |
| 1974 | return .{ | 1974 | return .{ |
| 1975 | .index = 0, | 1975 | .index = 0, |
| ... | @@ -2019,7 +2019,7 @@ test "tokenizeScalar" { | ... | @@ -2019,7 +2019,7 @@ test "tokenizeScalar" { |
| 2019 | try testing.expect(it16.next() == null); | 2019 | try testing.expect(it16.next() == null); |
| 2020 | } | 2020 | } |
| 2021 | | 2021 | |
| 2022 | test "tokenizeAny (multibyte)" { | 2022 | test "tokenizeAny" { |
| 2023 | var it = tokenizeAny(u8, "a|b,c/d e", " /,|"); | 2023 | var it = tokenizeAny(u8, "a|b,c/d e", " /,|"); |
| 2024 | try testing.expect(eql(u8, it.next().?, "a")); | 2024 | try testing.expect(eql(u8, it.next().?, "a")); |
| 2025 | try testing.expect(eql(u8, it.peek().?, "b")); | 2025 | try testing.expect(eql(u8, it.peek().?, "b")); |
| ... | @@ -2047,8 +2047,8 @@ test "tokenizeAny (multibyte)" { | ... | @@ -2047,8 +2047,8 @@ test "tokenizeAny (multibyte)" { |
| 2047 | try testing.expect(it16.next() == null); | 2047 | try testing.expect(it16.next() == null); |
| 2048 | } | 2048 | } |
| 2049 | | 2049 | |
| 2050 | test "tokenizeFull" { | 2050 | test "tokenizeSequence" { |
| 2051 | var it = tokenizeFull(u8, "a<>b<><>c><>d><", "<>"); | 2051 | var it = tokenizeSequence(u8, "a<>b<><>c><>d><", "<>"); |
| 2052 | try testing.expectEqualStrings("a", it.next().?); | 2052 | try testing.expectEqualStrings("a", it.next().?); |
| 2053 | try testing.expectEqualStrings("b", it.peek().?); | 2053 | try testing.expectEqualStrings("b", it.peek().?); |
| 2054 | try testing.expectEqualStrings("b", it.next().?); | 2054 | try testing.expectEqualStrings("b", it.next().?); |
| ... | @@ -2057,7 +2057,7 @@ test "tokenizeFull" { | ... | @@ -2057,7 +2057,7 @@ test "tokenizeFull" { |
| 2057 | try testing.expect(it.next() == null); | 2057 | try testing.expect(it.next() == null); |
| 2058 | try testing.expect(it.peek() == null); | 2058 | try testing.expect(it.peek() == null); |
| 2059 | | 2059 | |
| 2060 | var it16 = tokenizeFull( | 2060 | var it16 = tokenizeSequence( |
| 2061 | u16, | 2061 | u16, |
| 2062 | std.unicode.utf8ToUtf16LeStringLiteral("a<>b<><>c><>d><"), | 2062 | std.unicode.utf8ToUtf16LeStringLiteral("a<>b<><>c><>d><"), |
| 2063 | std.unicode.utf8ToUtf16LeStringLiteral("<>"), | 2063 | std.unicode.utf8ToUtf16LeStringLiteral("<>"), |
| ... | @@ -2084,7 +2084,7 @@ test "tokenize (reset)" { | ... | @@ -2084,7 +2084,7 @@ test "tokenize (reset)" { |
| 2084 | try testing.expect(it.next() == null); | 2084 | try testing.expect(it.next() == null); |
| 2085 | } | 2085 | } |
| 2086 | { | 2086 | { |
| 2087 | var it = tokenizeFull(u8, "<><>abc<>def<><>ghi<>", "<>"); | 2087 | var it = tokenizeSequence(u8, "<><>abc<>def<><>ghi<>", "<>"); |
| 2088 | try testing.expect(eql(u8, it.next().?, "abc")); | 2088 | try testing.expect(eql(u8, it.next().?, "abc")); |
| 2089 | try testing.expect(eql(u8, it.next().?, "def")); | 2089 | try testing.expect(eql(u8, it.next().?, "def")); |
| 2090 | try testing.expect(eql(u8, it.next().?, "ghi")); | 2090 | try testing.expect(eql(u8, it.next().?, "ghi")); |
| ... | @@ -2111,23 +2111,23 @@ test "tokenize (reset)" { | ... | @@ -2111,23 +2111,23 @@ test "tokenize (reset)" { |
| 2111 | } | 2111 | } |
| 2112 | } | 2112 | } |
| 2113 | | 2113 | |
| 2114 | /// Deprecated: use `splitFull`, `splitAny`, or `splitScalar` | 2114 | /// Deprecated: use `splitSequence`, `splitAny`, or `splitScalar` |
| 2115 | pub const split = splitFull; | 2115 | pub const split = splitSequence; |
| 2116 | | 2116 | |
| 2117 | /// Returns an iterator that iterates over the slices of `buffer` that | 2117 | /// Returns an iterator that iterates over the slices of `buffer` that |
| 2118 | /// are separated by the byte sequence in `delimiter`. | 2118 | /// are separated by the byte sequence in `delimiter`. |
| 2119 | /// | 2119 | /// |
| 2120 | /// `splitFull(u8, "abc||def||||ghi", "||")` will return slices | 2120 | /// `splitSequence(u8, "abc||def||||ghi", "||")` will return slices |
| 2121 | /// for "abc", "def", "", "ghi", null, in that order. | 2121 | /// for "abc", "def", "", "ghi", null, in that order. |
| 2122 | /// | 2122 | /// |
| 2123 | /// If `delimiter` does not exist in buffer, | 2123 | /// If `delimiter` does not exist in buffer, |
| 2124 | /// the iterator will return `buffer`, null, in that order. | 2124 | /// the iterator will return `buffer`, null, in that order. |
| 2125 | /// The delimiter length must not be zero. | 2125 | /// The delimiter length must not be zero. |
| 2126 | /// | 2126 | /// |
| 2127 | /// See also: `splitAny`, `splitScalar`, `splitBackwardsFull`, | 2127 | /// See also: `splitAny`, `splitScalar`, `splitBackwardsSequence`, |
| 2128 | /// `splitBackwardsAny`,`splitBackwardsScalar`, | 2128 | /// `splitBackwardsAny`,`splitBackwardsScalar`, |
| 2129 | /// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`. | 2129 | /// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`. |
| 2130 | pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .full) { | 2130 | pub fn splitSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .sequence) { |
| 2131 | assert(delimiter.len != 0); | 2131 | assert(delimiter.len != 0); |
| 2132 | return .{ | 2132 | return .{ |
| 2133 | .index = 0, | 2133 | .index = 0, |
| ... | @@ -2145,9 +2145,9 @@ pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) Spli | ... | @@ -2145,9 +2145,9 @@ pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) Spli |
| 2145 | /// If none of `delimiters` exist in buffer, | 2145 | /// If none of `delimiters` exist in buffer, |
| 2146 | /// the iterator will return `buffer`, null, in that order. | 2146 | /// the iterator will return `buffer`, null, in that order. |
| 2147 | /// | 2147 | /// |
| 2148 | /// See also: `splitFull`, `splitScalar`, `splitBackwardsFull`, | 2148 | /// See also: `splitSequence`, `splitScalar`, `splitBackwardsSequence`, |
| 2149 | /// `splitBackwardsAny`,`splitBackwardsScalar`, | 2149 | /// `splitBackwardsAny`,`splitBackwardsScalar`, |
| 2150 | /// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`. | 2150 | /// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`. |
| 2151 | pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitIterator(T, .any) { | 2151 | pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitIterator(T, .any) { |
| 2152 | return .{ | 2152 | return .{ |
| 2153 | .index = 0, | 2153 | .index = 0, |
| ... | @@ -2165,9 +2165,9 @@ pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) Spli | ... | @@ -2165,9 +2165,9 @@ pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) Spli |
| 2165 | /// If `delimiter` does not exist in buffer, | 2165 | /// If `delimiter` does not exist in buffer, |
| 2166 | /// the iterator will return `buffer`, null, in that order. | 2166 | /// the iterator will return `buffer`, null, in that order. |
| 2167 | /// | 2167 | /// |
| 2168 | /// See also: `splitFull`, `splitAny`, `splitBackwardsFull`, | 2168 | /// See also: `splitSequence`, `splitAny`, `splitBackwardsSequence`, |
| 2169 | /// `splitBackwardsAny`,`splitBackwardsScalar`, | 2169 | /// `splitBackwardsAny`,`splitBackwardsScalar`, |
| 2170 | /// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`. | 2170 | /// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`. |
| 2171 | pub fn splitScalar(comptime T: type, buffer: []const T, delimiter: T) SplitIterator(T, .scalar) { | 2171 | pub fn splitScalar(comptime T: type, buffer: []const T, delimiter: T) SplitIterator(T, .scalar) { |
| 2172 | return .{ | 2172 | return .{ |
| 2173 | .index = 0, | 2173 | .index = 0, |
| ... | @@ -2215,8 +2215,8 @@ test "splitScalar" { | ... | @@ -2215,8 +2215,8 @@ test "splitScalar" { |
| 2215 | try testing.expect(it16.next() == null); | 2215 | try testing.expect(it16.next() == null); |
| 2216 | } | 2216 | } |
| 2217 | | 2217 | |
| 2218 | test "splitFull (multibyte)" { | 2218 | test "splitSequence" { |
| 2219 | var it = splitFull(u8, "a, b ,, c, d, e", ", "); | 2219 | var it = splitSequence(u8, "a, b ,, c, d, e", ", "); |
| 2220 | try testing.expectEqualSlices(u8, it.first(), "a"); | 2220 | try testing.expectEqualSlices(u8, it.first(), "a"); |
| 2221 | try testing.expectEqualSlices(u8, it.rest(), "b ,, c, d, e"); | 2221 | try testing.expectEqualSlices(u8, it.rest(), "b ,, c, d, e"); |
| 2222 | try testing.expectEqualSlices(u8, it.next().?, "b ,"); | 2222 | try testing.expectEqualSlices(u8, it.next().?, "b ,"); |
| ... | @@ -2225,7 +2225,7 @@ test "splitFull (multibyte)" { | ... | @@ -2225,7 +2225,7 @@ test "splitFull (multibyte)" { |
| 2225 | try testing.expectEqualSlices(u8, it.next().?, "e"); | 2225 | try testing.expectEqualSlices(u8, it.next().?, "e"); |
| 2226 | try testing.expect(it.next() == null); | 2226 | try testing.expect(it.next() == null); |
| 2227 | | 2227 | |
| 2228 | var it16 = splitFull( | 2228 | var it16 = splitSequence( |
| 2229 | u16, | 2229 | u16, |
| 2230 | std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"), | 2230 | std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"), |
| 2231 | std.unicode.utf8ToUtf16LeStringLiteral(", "), | 2231 | std.unicode.utf8ToUtf16LeStringLiteral(", "), |
| ... | @@ -2269,7 +2269,7 @@ test "splitAny" { | ... | @@ -2269,7 +2269,7 @@ test "splitAny" { |
| 2269 | | 2269 | |
| 2270 | test "split (reset)" { | 2270 | test "split (reset)" { |
| 2271 | { | 2271 | { |
| 2272 | var it = splitFull(u8, "abc def ghi", " "); | 2272 | var it = splitSequence(u8, "abc def ghi", " "); |
| 2273 | try testing.expect(eql(u8, it.first(), "abc")); | 2273 | try testing.expect(eql(u8, it.first(), "abc")); |
| 2274 | try testing.expect(eql(u8, it.next().?, "def")); | 2274 | try testing.expect(eql(u8, it.next().?, "def")); |
| 2275 | try testing.expect(eql(u8, it.next().?, "ghi")); | 2275 | try testing.expect(eql(u8, it.next().?, "ghi")); |
| ... | @@ -2309,13 +2309,13 @@ test "split (reset)" { | ... | @@ -2309,13 +2309,13 @@ test "split (reset)" { |
| 2309 | } | 2309 | } |
| 2310 | } | 2310 | } |
| 2311 | | 2311 | |
| 2312 | /// Deprecated: use `splitBackwardsFull`, `splitBackwardsAny`, or `splitBackwardsScalar` | 2312 | /// Deprecated: use `splitBackwardsSequence`, `splitBackwardsAny`, or `splitBackwardsScalar` |
| 2313 | pub const splitBackwards = splitBackwardsFull; | 2313 | pub const splitBackwards = splitBackwardsSequence; |
| 2314 | | 2314 | |
| 2315 | /// Returns an iterator that iterates backwards over the slices of `buffer` that | 2315 | /// Returns an iterator that iterates backwards over the slices of `buffer` that |
| 2316 | /// are separated by the sequence in `delimiter`. | 2316 | /// are separated by the sequence in `delimiter`. |
| 2317 | /// | 2317 | /// |
| 2318 | /// `splitBackwardsFull(u8, "abc||def||||ghi", "||")` will return slices | 2318 | /// `splitBackwardsSequence(u8, "abc||def||||ghi", "||")` will return slices |
| 2319 | /// for "ghi", "", "def", "abc", null, in that order. | 2319 | /// for "ghi", "", "def", "abc", null, in that order. |
| 2320 | /// | 2320 | /// |
| 2321 | /// If `delimiter` does not exist in buffer, | 2321 | /// If `delimiter` does not exist in buffer, |
| ... | @@ -2323,9 +2323,9 @@ pub const splitBackwards = splitBackwardsFull; | ... | @@ -2323,9 +2323,9 @@ pub const splitBackwards = splitBackwardsFull; |
| 2323 | /// The delimiter length must not be zero. | 2323 | /// The delimiter length must not be zero. |
| 2324 | /// | 2324 | /// |
| 2325 | /// See also: `splitBackwardsAny`, `splitBackwardsScalar`, | 2325 | /// See also: `splitBackwardsAny`, `splitBackwardsScalar`, |
| 2326 | /// `splitFull`, `splitAny`,`splitScalar`, | 2326 | /// `splitSequence`, `splitAny`,`splitScalar`, |
| 2327 | /// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`. | 2327 | /// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`. |
| 2328 | pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []const T) SplitBackwardsIterator(T, .full) { | 2328 | pub fn splitBackwardsSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitBackwardsIterator(T, .sequence) { |
| 2329 | assert(delimiter.len != 0); | 2329 | assert(delimiter.len != 0); |
| 2330 | return .{ | 2330 | return .{ |
| 2331 | .index = buffer.len, | 2331 | .index = buffer.len, |
| ... | @@ -2343,9 +2343,9 @@ pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []cons | ... | @@ -2343,9 +2343,9 @@ pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []cons |
| 2343 | /// If none of `delimiters` exist in buffer, | 2343 | /// If none of `delimiters` exist in buffer, |
| 2344 | /// the iterator will return `buffer`, null, in that order. | 2344 | /// the iterator will return `buffer`, null, in that order. |
| 2345 | /// | 2345 | /// |
| 2346 | /// See also: `splitBackwardsFull`, `splitBackwardsScalar`, | 2346 | /// See also: `splitBackwardsSequence`, `splitBackwardsScalar`, |
| 2347 | /// `splitFull`, `splitAny`,`splitScalar`, | 2347 | /// `splitSequence`, `splitAny`,`splitScalar`, |
| 2348 | /// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`. | 2348 | /// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`. |
| 2349 | pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitBackwardsIterator(T, .any) { | 2349 | pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitBackwardsIterator(T, .any) { |
| 2350 | return .{ | 2350 | return .{ |
| 2351 | .index = buffer.len, | 2351 | .index = buffer.len, |
| ... | @@ -2363,9 +2363,9 @@ pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []cons | ... | @@ -2363,9 +2363,9 @@ pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []cons |
| 2363 | /// If `delimiter` does not exist in buffer, | 2363 | /// If `delimiter` does not exist in buffer, |
| 2364 | /// the iterator will return `buffer`, null, in that order. | 2364 | /// the iterator will return `buffer`, null, in that order. |
| 2365 | /// | 2365 | /// |
| 2366 | /// See also: `splitBackwardsFull`, `splitBackwardsAny`, | 2366 | /// See also: `splitBackwardsSequence`, `splitBackwardsAny`, |
| 2367 | /// `splitFull`, `splitAny`,`splitScalar`, | 2367 | /// `splitSequence`, `splitAny`,`splitScalar`, |
| 2368 | /// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`. | 2368 | /// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`. |
| 2369 | pub fn splitBackwardsScalar(comptime T: type, buffer: []const T, delimiter: T) SplitBackwardsIterator(T, .scalar) { | 2369 | pub fn splitBackwardsScalar(comptime T: type, buffer: []const T, delimiter: T) SplitBackwardsIterator(T, .scalar) { |
| 2370 | return .{ | 2370 | return .{ |
| 2371 | .index = buffer.len, | 2371 | .index = buffer.len, |
| ... | @@ -2413,8 +2413,8 @@ test "splitBackwardsScalar" { | ... | @@ -2413,8 +2413,8 @@ test "splitBackwardsScalar" { |
| 2413 | try testing.expect(it16.next() == null); | 2413 | try testing.expect(it16.next() == null); |
| 2414 | } | 2414 | } |
| 2415 | | 2415 | |
| 2416 | test "splitBackwardsFull (multibyte)" { | 2416 | test "splitBackwardsSequence" { |
| 2417 | var it = splitBackwardsFull(u8, "a, b ,, c, d, e", ", "); | 2417 | var it = splitBackwardsSequence(u8, "a, b ,, c, d, e", ", "); |
| 2418 | try testing.expectEqualSlices(u8, it.rest(), "a, b ,, c, d, e"); | 2418 | try testing.expectEqualSlices(u8, it.rest(), "a, b ,, c, d, e"); |
| 2419 | try testing.expectEqualSlices(u8, it.first(), "e"); | 2419 | try testing.expectEqualSlices(u8, it.first(), "e"); |
| 2420 | | 2420 | |
| ... | @@ -2433,7 +2433,7 @@ test "splitBackwardsFull (multibyte)" { | ... | @@ -2433,7 +2433,7 @@ test "splitBackwardsFull (multibyte)" { |
| 2433 | try testing.expectEqualSlices(u8, it.rest(), ""); | 2433 | try testing.expectEqualSlices(u8, it.rest(), ""); |
| 2434 | try testing.expect(it.next() == null); | 2434 | try testing.expect(it.next() == null); |
| 2435 | | 2435 | |
| 2436 | var it16 = splitBackwardsFull( | 2436 | var it16 = splitBackwardsSequence( |
| 2437 | u16, | 2437 | u16, |
| 2438 | std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"), | 2438 | std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"), |
| 2439 | std.unicode.utf8ToUtf16LeStringLiteral(", "), | 2439 | std.unicode.utf8ToUtf16LeStringLiteral(", "), |
| ... | @@ -2485,7 +2485,7 @@ test "splitBackwardsAny" { | ... | @@ -2485,7 +2485,7 @@ test "splitBackwardsAny" { |
| 2485 | | 2485 | |
| 2486 | test "splitBackwards (reset)" { | 2486 | test "splitBackwards (reset)" { |
| 2487 | { | 2487 | { |
| 2488 | var it = splitBackwardsFull(u8, "abc def ghi", " "); | 2488 | var it = splitBackwardsSequence(u8, "abc def ghi", " "); |
| 2489 | try testing.expect(eql(u8, it.first(), "ghi")); | 2489 | try testing.expect(eql(u8, it.first(), "ghi")); |
| 2490 | try testing.expect(eql(u8, it.next().?, "def")); | 2490 | try testing.expect(eql(u8, it.next().?, "def")); |
| 2491 | try testing.expect(eql(u8, it.next().?, "abc")); | 2491 | try testing.expect(eql(u8, it.next().?, "abc")); |
| ... | @@ -2693,13 +2693,13 @@ test "endsWith" { | ... | @@ -2693,13 +2693,13 @@ test "endsWith" { |
| 2693 | try testing.expect(!endsWith(u8, "Bob", "Bo")); | 2693 | try testing.expect(!endsWith(u8, "Bob", "Bo")); |
| 2694 | } | 2694 | } |
| 2695 | | 2695 | |
| 2696 | pub const DelimiterType = enum { full, any, scalar }; | 2696 | pub const DelimiterType = enum { sequence, any, scalar }; |
| 2697 | | 2697 | |
| 2698 | pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) type { | 2698 | pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) type { |
| 2699 | return struct { | 2699 | return struct { |
| 2700 | buffer: []const T, | 2700 | buffer: []const T, |
| 2701 | delimiter: switch (delimiter_type) { | 2701 | delimiter: switch (delimiter_type) { |
| 2702 | .full, .any => []const T, | 2702 | .sequence, .any => []const T, |
| 2703 | .scalar => T, | 2703 | .scalar => T, |
| 2704 | }, | 2704 | }, |
| 2705 | index: usize, | 2705 | index: usize, |
| ... | @@ -2719,7 +2719,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t | ... | @@ -2719,7 +2719,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t |
| 2719 | pub fn peek(self: *Self) ?[]const T { | 2719 | pub fn peek(self: *Self) ?[]const T { |
| 2720 | // move to beginning of token | 2720 | // move to beginning of token |
| 2721 | while (self.index < self.buffer.len and self.isDelimiter(self.index)) : (self.index += switch (delimiter_type) { | 2721 | while (self.index < self.buffer.len and self.isDelimiter(self.index)) : (self.index += switch (delimiter_type) { |
| 2722 | .full => self.delimiter.len, | 2722 | .sequence => self.delimiter.len, |
| 2723 | .any, .scalar => 1, | 2723 | .any, .scalar => 1, |
| 2724 | }) {} | 2724 | }) {} |
| 2725 | const start = self.index; | 2725 | const start = self.index; |
| ... | @@ -2739,7 +2739,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t | ... | @@ -2739,7 +2739,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t |
| 2739 | // move to beginning of token | 2739 | // move to beginning of token |
| 2740 | var index: usize = self.index; | 2740 | var index: usize = self.index; |
| 2741 | while (index < self.buffer.len and self.isDelimiter(index)) : (index += switch (delimiter_type) { | 2741 | while (index < self.buffer.len and self.isDelimiter(index)) : (index += switch (delimiter_type) { |
| 2742 | .full => self.delimiter.len, | 2742 | .sequence => self.delimiter.len, |
| 2743 | .any, .scalar => 1, | 2743 | .any, .scalar => 1, |
| 2744 | }) {} | 2744 | }) {} |
| 2745 | return self.buffer[index..]; | 2745 | return self.buffer[index..]; |
| ... | @@ -2752,7 +2752,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t | ... | @@ -2752,7 +2752,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t |
| 2752 | | 2752 | |
| 2753 | fn isDelimiter(self: Self, index: usize) bool { | 2753 | fn isDelimiter(self: Self, index: usize) bool { |
| 2754 | switch (delimiter_type) { | 2754 | switch (delimiter_type) { |
| 2755 | .full => return startsWith(T, self.buffer[index..], self.delimiter), | 2755 | .sequence => return startsWith(T, self.buffer[index..], self.delimiter), |
| 2756 | .any => { | 2756 | .any => { |
| 2757 | const item = self.buffer[index]; | 2757 | const item = self.buffer[index]; |
| 2758 | for (self.delimiter) |delimiter_item| { | 2758 | for (self.delimiter) |delimiter_item| { |
| ... | @@ -2773,7 +2773,7 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t | ... | @@ -2773,7 +2773,7 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t |
| 2773 | buffer: []const T, | 2773 | buffer: []const T, |
| 2774 | index: ?usize, | 2774 | index: ?usize, |
| 2775 | delimiter: switch (delimiter_type) { | 2775 | delimiter: switch (delimiter_type) { |
| 2776 | .full, .any => []const T, | 2776 | .sequence, .any => []const T, |
| 2777 | .scalar => T, | 2777 | .scalar => T, |
| 2778 | }, | 2778 | }, |
| 2779 | | 2779 | |
| ... | @@ -2790,12 +2790,12 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t | ... | @@ -2790,12 +2790,12 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t |
| 2790 | pub fn next(self: *Self) ?[]const T { | 2790 | pub fn next(self: *Self) ?[]const T { |
| 2791 | const start = self.index orelse return null; | 2791 | const start = self.index orelse return null; |
| 2792 | const end = if (switch (delimiter_type) { | 2792 | const end = if (switch (delimiter_type) { |
| 2793 | .full => indexOfPos(T, self.buffer, start, self.delimiter), | 2793 | .sequence => indexOfPos(T, self.buffer, start, self.delimiter), |
| 2794 | .any => indexOfAnyPos(T, self.buffer, start, self.delimiter), | 2794 | .any => indexOfAnyPos(T, self.buffer, start, self.delimiter), |
| 2795 | .scalar => indexOfScalarPos(T, self.buffer, start, self.delimiter), | 2795 | .scalar => indexOfScalarPos(T, self.buffer, start, self.delimiter), |
| 2796 | }) |delim_start| blk: { | 2796 | }) |delim_start| blk: { |
| 2797 | self.index = delim_start + switch (delimiter_type) { | 2797 | self.index = delim_start + switch (delimiter_type) { |
| 2798 | .full => self.delimiter.len, | 2798 | .sequence => self.delimiter.len, |
| 2799 | .any, .scalar => 1, | 2799 | .any, .scalar => 1, |
| 2800 | }; | 2800 | }; |
| 2801 | break :blk delim_start; | 2801 | break :blk delim_start; |
| ... | @@ -2825,7 +2825,7 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit | ... | @@ -2825,7 +2825,7 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit |
| 2825 | buffer: []const T, | 2825 | buffer: []const T, |
| 2826 | index: ?usize, | 2826 | index: ?usize, |
| 2827 | delimiter: switch (delimiter_type) { | 2827 | delimiter: switch (delimiter_type) { |
| 2828 | .full, .any => []const T, | 2828 | .sequence, .any => []const T, |
| 2829 | .scalar => T, | 2829 | .scalar => T, |
| 2830 | }, | 2830 | }, |
| 2831 | | 2831 | |
| ... | @@ -2842,13 +2842,13 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit | ... | @@ -2842,13 +2842,13 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit |
| 2842 | pub fn next(self: *Self) ?[]const T { | 2842 | pub fn next(self: *Self) ?[]const T { |
| 2843 | const end = self.index orelse return null; | 2843 | const end = self.index orelse return null; |
| 2844 | const start = if (switch (delimiter_type) { | 2844 | const start = if (switch (delimiter_type) { |
| 2845 | .full => lastIndexOf(T, self.buffer[0..end], self.delimiter), | 2845 | .sequence => lastIndexOf(T, self.buffer[0..end], self.delimiter), |
| 2846 | .any => lastIndexOfAny(T, self.buffer[0..end], self.delimiter), | 2846 | .any => lastIndexOfAny(T, self.buffer[0..end], self.delimiter), |
| 2847 | .scalar => lastIndexOfScalar(T, self.buffer[0..end], self.delimiter), | 2847 | .scalar => lastIndexOfScalar(T, self.buffer[0..end], self.delimiter), |
| 2848 | }) |delim_start| blk: { | 2848 | }) |delim_start| blk: { |
| 2849 | self.index = delim_start; | 2849 | self.index = delim_start; |
| 2850 | break :blk delim_start + switch (delimiter_type) { | 2850 | break :blk delim_start + switch (delimiter_type) { |
| 2851 | .full => self.delimiter.len, | 2851 | .sequence => self.delimiter.len, |
| 2852 | .any, .scalar => 1, | 2852 | .any, .scalar => 1, |
| 2853 | }; | 2853 | }; |
| 2854 | } else blk: { | 2854 | } else blk: { |