Function collapseRepeats [src]
Collapse consecutive duplicate elements into one entry.
Prototype
pub fn collapseRepeats(comptime T: type, slice: []T, elem: T) []T
Parameters
T: type
slice: []T
elem: T
Example
test collapseRepeats {
try testCollapseRepeats("", '/', "");
try testCollapseRepeats("a", '/', "a");
try testCollapseRepeats("/", '/', "/");
try testCollapseRepeats("//", '/', "/");
try testCollapseRepeats("/a", '/', "/a");
try testCollapseRepeats("//a", '/', "/a");
try testCollapseRepeats("a/", '/', "a/");
try testCollapseRepeats("a//", '/', "a/");
try testCollapseRepeats("a/a", '/', "a/a");
try testCollapseRepeats("a//a", '/', "a/a");
try testCollapseRepeats("//a///a////", '/', "/a/a/");
}
Source
pub fn collapseRepeats(comptime T: type, slice: []T, elem: T) []T {
return slice[0..collapseRepeatsLen(T, slice, elem)];
}