authorgravatar for 124872+jedisct1@users.noreply.github.comFrank Denis <124872+jedisct1@users.noreply.github.com> 2023-02-20 00:36:05+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-02-20 13:55:45-05:00
log6214f66dc108bd34a3ffa1ba5ac7704050a2f156
tree1055fd80b1cf8eb9998f471ef8a9b8c1315219d3
parent5a7d80a5e7d0aaafc6ed3017e0e4342dcd476a51

trim(Left|Right): clarify that values_to_strip is a set

The parameter could be confused with a prefix or suffix, instead of a set of values.

1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/mem.zig+3-3
......@@ -941,21 +941,21 @@ pub fn allEqual(comptime T: type, slice: []const T, scalar: T) bool {
941941 return true;
942942}
943943
944/// Remove values from the beginning of a slice.
944/// Remove a set of values from the beginning of a slice.
945945pub fn trimLeft(comptime T: type, slice: []const T, values_to_strip: []const T) []const T {
946946 var begin: usize = 0;
947947 while (begin < slice.len and indexOfScalar(T, values_to_strip, slice[begin]) != null) : (begin += 1) {}
948948 return slice[begin..];
949949}
950950
951/// Remove values from the end of a slice.
951/// Remove a set of values from the end of a slice.
952952pub fn trimRight(comptime T: type, slice: []const T, values_to_strip: []const T) []const T {
953953 var end: usize = slice.len;
954954 while (end > 0 and indexOfScalar(T, values_to_strip, slice[end - 1]) != null) : (end -= 1) {}
955955 return slice[0..end];
956956}
957957
958/// Remove values from the beginning and end of a slice.
958/// Remove a set of values from the beginning and end of a slice.
959959pub fn trim(comptime T: type, slice: []const T, values_to_strip: []const T) []const T {
960960 var begin: usize = 0;
961961 var end: usize = slice.len;