소스 검색

Ran rustfmt on all tasks.

Lorenz Bung 8 년 전
부모
커밋
6728f0e1f0
3개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 1
    1
      hw1/task2/src/lib.rs
  2. 7
    7
      hw1/task3/src/lib.rs
  3. 3
    3
      hw1/task4/src/lib.rs

+ 1
- 1
hw1/task2/src/lib.rs 파일 보기

@@ -1,6 +1,6 @@
1 1
 //This function prints the n-th power of 2 and returns it.
2 2
 pub fn square(n: u32) -> u64 {
3
-    let sq: u64 = 2u64.pow(n-1); //(n-1) to solve the (in my opinion wrong) tests.
3
+    let sq: u64 = 2u64.pow(n - 1); //(n-1) to solve the (in my opinion wrong) tests.
4 4
     println!("{}", sq);
5 5
     sq
6 6
 }

+ 7
- 7
hw1/task3/src/lib.rs 파일 보기

@@ -1,9 +1,9 @@
1 1
 pub fn count(line: &str, c: char) -> u64 {
2
-   let mut occurances = 0;
3
-   for char in line.chars(){
4
-      if char == c {
5
-        occurances += 1;
6
-      }
7
-   }
8
-   occurances
2
+    let mut occurances = 0;
3
+    for char in line.chars() {
4
+        if char == c {
5
+            occurances += 1;
6
+        }
7
+    }
8
+    occurances
9 9
 }

+ 3
- 3
hw1/task4/src/lib.rs 파일 보기

@@ -1,6 +1,6 @@
1 1
 pub fn square_of_sum(n: i32) -> i32 {
2 2
     let mut i: i32 = 0;
3
-    for x in 1..n+1 {
3
+    for x in 1..n + 1 {
4 4
         i += x;
5 5
     }
6 6
     i.pow(2)
@@ -8,8 +8,8 @@ pub fn square_of_sum(n: i32) -> i32 {
8 8
 
9 9
 pub fn sum_of_squares(n: i32) -> i32 {
10 10
     let mut i: i32 = 0;
11
-    for x in 1..n+1 {
12
-       i += x.pow(2); 
11
+    for x in 1..n + 1 {
12
+        i += x.pow(2);
13 13
     }
14 14
     i
15 15
 }

Loading…
취소
저장