Some fixes to string. Added fprintf and String.printf. Updated boolerr example.

This commit is contained in:
Christoffer Lerno
2022-07-26 13:44:08 +02:00
parent da4df9d626
commit 7065c28a08
4 changed files with 65 additions and 30 deletions

View File

@@ -75,7 +75,8 @@ fn void String.chop(String this, usize new_size)
fn char[] String.str(String str)
{
StringData* data = (StringData*)str;
return data.chars[0..data.len - 1];
if (!data) return char[] {};
return data.chars[:data.len];
}
fn void String.append_utf32(String* str, Char32[] chars)
@@ -173,6 +174,11 @@ fn ZString String.copy_zstr(String* str, Allocator allocator = { null, null })
return (ZString)zstr;
}
fn char[] String.copy_str(String* str, Allocator allocator = { null, null })
{
return str.copy_zstr(allocator)[:str.len()];
}
fn bool String.equals(String str, String other_string)
{
StringData *str1 = str.data();