mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Support untyped second argument for operator overloading.
- Distinct versions of builtin types ignore @operator overloads #2204. - @operator macro using untyped parameter causes compiler segfault #2200. - Add comparison with `==` for ZString types.
This commit is contained in:
@@ -577,6 +577,19 @@ fn usz? String.rindex_of(self, String substr)
|
||||
return NOT_FOUND?;
|
||||
}
|
||||
|
||||
fn bool ZString.eq(self, ZString other) @operator(==)
|
||||
{
|
||||
char* a = self;
|
||||
char* b = other;
|
||||
if (a == b) return true;
|
||||
for (;; a++, b++)
|
||||
{
|
||||
char c = *a;
|
||||
if (c != *b) return false;
|
||||
if (!c) return true;
|
||||
}
|
||||
}
|
||||
|
||||
fn String ZString.str_view(self)
|
||||
{
|
||||
return (String)(self[:self.len()]);
|
||||
|
||||
Reference in New Issue
Block a user