Function trimEnd [src]

Remove a set of values from the end of a slice.

Prototype

pub fn trimEnd(comptime T: type, slice: []const T, values_to_strip: []const T) []const T

Parameters

T: typeslice: []const Tvalues_to_strip: []const T

Example

test trimEnd { try testing.expectEqualSlices(u8, " foo", trimEnd(u8, " foo\n ", " \n")); }

Source

pub fn trimEnd(comptime T: type, slice: []const T, values_to_strip: []const T) []const T { var end: usize = slice.len; while (end > 0 and indexOfScalar(T, values_to_strip, slice[end - 1]) != null) : (end -= 1) {} return slice[0..end]; }