소스 검색

Added some methods.

Lorenz Bung 8 년 전
부모
커밋
2d83743796
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6
    2
      hw6/task1/src/main.rs

+ 6
- 2
hw6/task1/src/main.rs 파일 보기

@@ -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…
취소
저장