Add free to String, update hello_world_harder
This commit is contained in:
		
							parent
							
								
									1f56fa5dc3
								
							
						
					
					
						commit
						8838223a7d
					
				| @ -1,23 +1,16 @@ | |||||||
| import std::print; | import std::print; | ||||||
| import std::from_str; |  | ||||||
| import std::set_char; |  | ||||||
| import std::free_string; |  | ||||||
| import std::String; | import std::String; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| fn main() { | fn main() { | ||||||
|     let mut test = String::from("hello"); |     let mut test = String::from("hello"); | ||||||
| 
 | 
 | ||||||
|     test.push(String::from(" world")); |     test.push(String::from(" world: ")); | ||||||
| 
 |  | ||||||
|     test.add_char('!'); |  | ||||||
|     test.add_char('\n'); |  | ||||||
| 
 | 
 | ||||||
|     test.push_num(175); |     test.push_num(175); | ||||||
|      |      | ||||||
|     print(test); |     print(test); | ||||||
| 
 | 
 | ||||||
|     free_string(&test); |     test.free(); | ||||||
| 
 | 
 | ||||||
|     return; |     return; | ||||||
| } | } | ||||||
|  | |||||||
| @ -75,6 +75,10 @@ impl String { | |||||||
|         else if rem == 8 { self.add_char('8'); } |         else if rem == 8 { self.add_char('8'); } | ||||||
|         else if rem == 9 { self.add_char('9'); } |         else if rem == 9 { self.add_char('9'); } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     pub fn free(&self) { | ||||||
|  |         free((*self).inner as *u8); | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl binop (lhs: String) + (rhs: *char) -> String { | impl binop (lhs: String) + (rhs: *char) -> String { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user