~sircmpwn/hare

fd269b13cae1b1a972877b8ca48ef351aaa63bed — Sebastian 1 year, 11 days ago 7ec19f2
bytes: replace if expressions with logical and

Signed-off-by: Sebastian <sebastian@sebsite.pw>
1 files changed, 3 insertions(+), 4 deletions(-)

M bytes/contains.ha
M bytes/contains.ha => bytes/contains.ha +3 -4
@@ 19,8 19,7 @@ export fn contains(haystack: []u8, needles: (u8 | []u8)...) bool = {

// Returns true if "in" has the given prefix, false otherwise
export fn hasprefix(in: []u8, prefix: []u8) bool = {
	return if (len(in) < len(prefix)) false
		else equal(in[..len(prefix)], prefix);
	return len(in) >= len(prefix) && equal(in[..len(prefix)], prefix);
};

@test fn hasprefix() void = {


@@ 44,8 43,8 @@ export fn hasprefix(in: []u8, prefix: []u8) bool = {

// Returns true if "in" has the given suffix, false otherwise
export fn hassuffix(in: []u8, suffix: []u8) bool = {
	return if (len(in) < len(suffix)) false
		else equal(in[len(in) - len(suffix)..], suffix);
	return len(in) >= len(suffix)
		&& equal(in[len(in) - len(suffix)..], suffix);
};

@test fn hassuffix() void = {