mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Added some to_string.
This commit is contained in:
@@ -24,6 +24,16 @@ fn Type Range.get(Range* range, usz index) @operator([])
|
||||
return range.start + (Type)index;
|
||||
}
|
||||
|
||||
fn String Range.to_string(Range* list, Allocator* using = mem::heap()) @dynamic
|
||||
{
|
||||
return string::printf("[%s..%s]", list.start, list.end);
|
||||
}
|
||||
|
||||
fn void! Range.to_format(Range* list, Formatter* formatter) @dynamic
|
||||
{
|
||||
formatter.printf("[%s..%s]", list.start, list.end)!;
|
||||
}
|
||||
|
||||
struct ExclusiveRange
|
||||
{
|
||||
Type start;
|
||||
@@ -36,6 +46,16 @@ fn usz ExclusiveRange.len(ExclusiveRange* range) @operator(len)
|
||||
return (usz)(range.end - range.start);
|
||||
}
|
||||
|
||||
fn void! ExclusiveRange.to_format(ExclusiveRange* list, Formatter* formatter) @dynamic
|
||||
{
|
||||
formatter.printf("[%s..<%s]", list.start, list.end)!;
|
||||
}
|
||||
|
||||
fn String ExclusiveRange.to_string(ExclusiveRange* list, Allocator* using = mem::heap()) @dynamic
|
||||
{
|
||||
return string::printf("[%s..<%s]", list.start, list.end);
|
||||
}
|
||||
|
||||
/**
|
||||
* @require index < range.len() : "Can't index into an empty range"
|
||||
**/
|
||||
|
||||
Reference in New Issue
Block a user