Pārlūkot izejas kodu

Added some methods.

Lorenz Bung 8 gadus atpakaļ
vecāks
revīzija
2d83743796
1 mainītis faili ar 6 papildinājumiem un 2 dzēšanām
  1. 6
    2
      hw6/task1/src/main.rs

+ 6
- 2
hw6/task1/src/main.rs Parādīt failu

@@ -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(){

Notiek ielāde…
Atcelt
Saglabāt