Function endsWith [src]

Prototype

pub fn endsWith(comptime T: type, haystack: []const T, needle: []const T) bool

Parameters

T: typehaystack: []const Tneedle: []const T

Example

test endsWith { try testing.expect(endsWith(u8, "Needle in haystack", "haystack")); try testing.expect(!endsWith(u8, "Bob", "Bo")); }

Source

pub fn endsWith(comptime T: type, haystack: []const T, needle: []const T) bool { return if (needle.len > haystack.len) false else eql(T, haystack[haystack.len - needle.len ..], needle); }