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.

cutScalarLast

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

See also:

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

File

lib/std/mem.zig:3277

Code

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