From 8838223a7da59bd18333c3795573e7bba10c5466 Mon Sep 17 00:00:00 2001 From: sofia Date: Mon, 28 Jul 2025 00:44:52 +0300 Subject: [PATCH] Add free to String, update hello_world_harder --- examples/hello_world_harder.reid | 11 ++--------- reid/lib/std.reid | 4 ++++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/hello_world_harder.reid b/examples/hello_world_harder.reid index f3452e2..0132072 100644 --- a/examples/hello_world_harder.reid +++ b/examples/hello_world_harder.reid @@ -1,23 +1,16 @@ import std::print; -import std::from_str; -import std::set_char; -import std::free_string; import std::String; - fn main() { let mut test = String::from("hello"); - test.push(String::from(" world")); - - test.add_char('!'); - test.add_char('\n'); + test.push(String::from(" world: ")); test.push_num(175); print(test); - free_string(&test); + test.free(); return; } diff --git a/reid/lib/std.reid b/reid/lib/std.reid index 1abdebf..269ce49 100644 --- a/reid/lib/std.reid +++ b/reid/lib/std.reid @@ -75,6 +75,10 @@ impl String { else if rem == 8 { self.add_char('8'); } else if rem == 9 { self.add_char('9'); } } + + pub fn free(&self) { + free((*self).inner as *u8); + } } impl binop (lhs: String) + (rhs: *char) -> String {