mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add has function to Range and ExclusiveRange.
This commit is contained in:
committed by
Christoffer Lerno
parent
b453186de5
commit
7fbedae604
@@ -16,6 +16,11 @@ fn usz Range.len(&self) @operator(len)
|
||||
return (usz)(self.end - self.start + (Type)1);
|
||||
}
|
||||
|
||||
fn bool Range.has(&self, Type value) @inline
|
||||
{
|
||||
return value >= self.start && value <= self.end;
|
||||
}
|
||||
|
||||
/**
|
||||
* @require index < self.len() : "Can't index into an empty range"
|
||||
**/
|
||||
@@ -46,6 +51,11 @@ fn usz ExclusiveRange.len(&self) @operator(len)
|
||||
return (usz)(self.end - self.start);
|
||||
}
|
||||
|
||||
fn bool ExclusiveRange.has(&self, Type value) @inline
|
||||
{
|
||||
return value >= self.start && value < self.end;
|
||||
}
|
||||
|
||||
fn void! ExclusiveRange.to_format(&self, Formatter* formatter) @dynamic
|
||||
{
|
||||
formatter.printf("[%s..<%s]", self.start, self.end)!;
|
||||
|
||||
Reference in New Issue
Block a user