Update standard library documentation
This commit is contained in:
		
							parent
							
								
									8838223a7d
								
							
						
					
					
						commit
						00c91fff60
					
				| @ -10,30 +10,58 @@ Has the following binops defined: | |||||||
| - `String` + `*char` = `String` | - `String` + `*char` = `String` | ||||||
| - `String` + `u64` = `String` | - `String` + `u64` = `String` | ||||||
| 
 | 
 | ||||||
| #### `pub fn print(message: String)` | ##### `String::new() -> String` | ||||||
| 
 | 
 | ||||||
| Prints given `message` to the standard output | Returns a new empty `String`-object, which must later be manually freed. | ||||||
|  | 
 | ||||||
|  | ##### `String::from(str: *char) -> String` | ||||||
|  | 
 | ||||||
|  | Creates a new `String`-object containing initially data from the given string-literal which must be later freed. | ||||||
|  | 
 | ||||||
|  | ##### `String::set(&mut self, c: char, position: u64)` | ||||||
|  | 
 | ||||||
|  | Edits given `string` by setting the character at index `position` to be `c`. | ||||||
|  | 
 | ||||||
|  | ##### `String::push_num(&mut self, num: u64)` | ||||||
|  | 
 | ||||||
|  | Formats the given number into the end of the string. | ||||||
|  | 
 | ||||||
|  | ##### `String::concat(&mut self, source: String)` | ||||||
|  | 
 | ||||||
|  | Concatenates `source` to the end of `destination`. | ||||||
|  | 
 | ||||||
|  | ### Deprecated functions | ||||||
| 
 | 
 | ||||||
| #### `pub fn new_string() -> String` | #### `pub fn new_string() -> String` | ||||||
| 
 | 
 | ||||||
| Returns a new empty `String`-object, which must later be manually freed. | Returns a new empty `String`-object, which must later be manually freed. | ||||||
| 
 | 
 | ||||||
|  | _deprecated: Use `String::new()`_ | ||||||
|  | 
 | ||||||
| #### `pub fn from_str(string: *char) -> String` | #### `pub fn from_str(string: *char) -> String` | ||||||
| 
 | 
 | ||||||
| Creates a new `String`-object containing initially data from the given string-literal which must be later freed. | Creates a new `String`-object containing initially data from the given string-literal which must be later freed. | ||||||
| 
 | 
 | ||||||
|  | _deprecated: Use `String::from()`_ | ||||||
|  | 
 | ||||||
| #### `pub fn set_char(string: &mut String, c: char, position: u64)` | #### `pub fn set_char(string: &mut String, c: char, position: u64)` | ||||||
| 
 | 
 | ||||||
| Edits given `string` by setting the character at index `position` to be `c`. | Edits given `string` by setting the character at index `position` to be `c`. | ||||||
| 
 | 
 | ||||||
|  | _deprecated: Use `String::set()`_ | ||||||
|  | 
 | ||||||
| #### `pub fn add_num_to_string(string: &mut String, num: u64)` | #### `pub fn add_num_to_string(string: &mut String, num: u64)` | ||||||
| 
 | 
 | ||||||
| Formats the given number into the end of the string. | Formats the given number into the end of the string. | ||||||
| 
 | 
 | ||||||
|  | _deprecated: Use `String::push_num()`_ | ||||||
|  | 
 | ||||||
| #### `pub fn concat_strings(destination: &mut String, source: String)` | #### `pub fn concat_strings(destination: &mut String, source: String)` | ||||||
| 
 | 
 | ||||||
| Concatenates `source` to the end of `destination`. | Concatenates `source` to the end of `destination`. | ||||||
| 
 | 
 | ||||||
|  | _deprecated: Use `String::concat()`_ | ||||||
|  | 
 | ||||||
| ## General | ## General | ||||||
| 
 | 
 | ||||||
| #### `pub fn allocate(size: u64) -> *u8` | #### `pub fn allocate(size: u64) -> *u8` | ||||||
|  | |||||||
| @ -76,6 +76,18 @@ impl String { | |||||||
|         else if rem == 9 { self.add_char('9'); } |         else if rem == 9 { self.add_char('9'); } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     pub fn concat(&mut self, other: &String) { | ||||||
|  |         for i in 0 .. *other.length { | ||||||
|  |             self.add_char(*other.inner[i]); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     pub fn set(&mut self, c: char, position: u64) { | ||||||
|  |         if position <= (*self).length { | ||||||
|  |             (*self).inner[position] = c; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     pub fn free(&self) { |     pub fn free(&self) { | ||||||
|         free((*self).inner as *u8); |         free((*self).inner as *u8); | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user