Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

cutLast

Returns slice of haystack before and after last occurrence of needle, or null if not found.

See also:

mem.cutLast
pub fn cutLast(comptime T: type, haystack: []const T, needle: []const T) ?struct

File

lib/std/mem.zig:3239

Code

pub fn cutLast(comptime T: type, haystack: []const T, needle: []const T) ?struct { []const T, []const T } {
    const index = findLast(T, haystack, needle) orelse return null;
    return .{ haystack[0..index], haystack[index + needle.len ..] };
}