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 {