Skip to content

Commit dd2f1cb

Browse files
committed
std.mem: rename chomp to cut
1 parent ccaf82d commit dd2f1cb

File tree

2 files changed

+58
-58
lines changed

2 files changed

+58
-58
lines changed

lib/std/mem.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,23 +3080,23 @@ test endsWith {
30803080
}
30813081

30823082
/// If `slice` starts with `prefix`, returns the rest of `slice` starting at `prefix.len`.
3083-
pub fn chompPrefix(comptime T: type, slice: []const T, prefix: []const T) ?[]const T {
3083+
pub fn cutPrefix(comptime T: type, slice: []const T, prefix: []const T) ?[]const T {
30843084
return if (startsWith(T, slice, prefix)) slice[prefix.len..] else null;
30853085
}
30863086

3087-
test chompPrefix {
3088-
try testing.expectEqualStrings("foo", chompPrefix(u8, "--example=foo", "--example=").?);
3089-
try testing.expectEqual(null, chompPrefix(u8, "--example=foo", "-example="));
3087+
test cutPrefix {
3088+
try testing.expectEqualStrings("foo", cutPrefix(u8, "--example=foo", "--example=").?);
3089+
try testing.expectEqual(null, cutPrefix(u8, "--example=foo", "-example="));
30903090
}
30913091

30923092
/// If `slice` ends with `suffix`, returns `slice` from beginning to start of `suffix`.
3093-
pub fn chompSuffix(comptime T: type, slice: []const T, suffix: []const T) ?[]const T {
3093+
pub fn cutSuffix(comptime T: type, slice: []const T, suffix: []const T) ?[]const T {
30943094
return if (endsWith(T, slice, suffix)) slice[0 .. slice.len - suffix.len] else null;
30953095
}
30963096

3097-
test chompSuffix {
3098-
try testing.expectEqualStrings("foo", chompSuffix(u8, "foobar", "bar").?);
3099-
try testing.expectEqual(null, chompSuffix(u8, "foobar", "baz"));
3097+
test cutSuffix {
3098+
try testing.expectEqualStrings("foo", cutSuffix(u8, "foobar", "bar").?);
3099+
try testing.expectEqual(null, cutSuffix(u8, "foobar", "baz"));
31003100
}
31013101

31023102
/// Delimiter type for tokenization and splitting operations.

0 commit comments

Comments
 (0)