From 71b4af57bdcc91d948d436a459a223c402a6e17d Mon Sep 17 00:00:00 2001 From: A404M Date: Tue, 10 Jun 2025 17:23:56 +0330 Subject: add more functions to string --- code/lib/io.felan | 2 +- code/lib/string.felan | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'code/lib') diff --git a/code/lib/io.felan b/code/lib/io.felan index 413da8d..d470331 100644 --- a/code/lib/io.felan +++ b/code/lib/io.felan @@ -72,7 +72,7 @@ _print_unsigned :: (comptime t:type, value:t) -> void { } {} while i < NUMBERS_SIZE - 1 { - @putc(numbers[i]); + print_char(numbers[i]); i += 1; } return; diff --git a/code/lib/string.felan b/code/lib/string.felan index 4b5452f..789b0fb 100644 --- a/code/lib/string.felan +++ b/code/lib/string.felan @@ -67,6 +67,16 @@ _grow_if_needed :: (this:*String, count:u64) -> void { } }; +slice :: (this:String, begin:i64, end:i64) -> String { + result:String = undefined; + + result.ptr = this.ptr + begin; + result.size = @cast(end-begin,u64); + result.capacity = 0u64; + + return result; +}; + delete :: (this:String) -> void { free(this.ptr); }; @@ -74,7 +84,7 @@ delete :: (this:String) -> void { print :: (this:String) -> void { i := 0u64; while i < this.size { - @putc(this[i]); + print_char(this[i]); i += 1u64; } }; -- cgit v1.2.3