Explorar el Código

Added some methods.

Lorenz Bung hace 8 años
padre
commit
2d83743796
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  1. 6
    2
      hw6/task1/src/main.rs

+ 6
- 2
hw6/task1/src/main.rs Ver fichero

@@ -2,10 +2,14 @@ fn main() {
2 2
     println!("Hello, world!");
3 3
 }
4 4
 
5
-fn concatenate_strings(){
5
+/// Concats the two given String *references* and returns them as a String.
6
+fn concatenate_strings<'a>(s1:&'a str, s2:&'a str) -> String {
7
+    s1.to_string() + s2
6 8
 }
7 9
 
8
-fn split_into_strings(){
10
+/// Splits the given String *reference* and returns it as Vector of Strings.
11
+fn split_into_strings<'a>(s1:&'a str) -> Vec<String> {
12
+    s1.to_string().split_whitespace().collect()
9 13
 }
10 14
 
11 15
 fn sum_strings(){

Loading…
Cancelar
Guardar