Skip to content

Commit 4fcaef9

Browse files
committed
*
1 parent 357e134 commit 4fcaef9

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

rust/src/main.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ fn references() {
151151

152152
#[test]
153153
fn data_structures() {
154-
// classsic struct
154+
// classic struct
155155

156156
#[allow(dead_code)]
157-
#[derive(Debug)] // requried for `format!("{:?}", p)`
157+
#[derive(Debug)] // required for `format!("{:?}", p)`
158158
struct Person {
159159
name: String,
160160
age: u8,
@@ -181,7 +181,7 @@ fn tuples() {
181181
let Pair(integer, decimal) = pair;
182182
assert_eq!(integer, 1);
183183
assert_eq!(decimal, 0.1);
184-
static GLOBAL: i32 = 1; // statics need to be upppercase
184+
static GLOBAL: i32 = 1; // statics need to be uppercase
185185
assert_eq!(GLOBAL, 1);
186186

187187
// generics are like template in C++
@@ -193,13 +193,13 @@ fn tuples() {
193193

194194
#[test]
195195
fn traits() {
196-
// a trait is like an intrafce, can contain virtual functions
196+
// a trait is like an interface, can contain virtual functions
197197
trait Zero {
198198
const ZERO: Self;
199199
fn is_zero(&self) -> bool;
200200
}
201201

202-
// implemenataions must implement their interface
202+
// implementations must implement their interface
203203
impl Zero for i32 {
204204
const ZERO: Self = 0;
205205

@@ -267,7 +267,7 @@ fn scope() {
267267
// value of a is unusable here
268268
assert_eq!(c, "1");
269269
a = c;
270-
// c is unusable because is unmutable
270+
// c is unusable because is immutable
271271
//c = a; // error: cannot assign twice to immutable variable
272272
assert_eq!(a, "1");
273273
}
@@ -286,26 +286,31 @@ fn mutable_function_argument() {
286286
let c = b + "d"; // content of b is moved here
287287
// b is unusable here
288288
assert_eq!(c, "abcd");
289-
a = c; // reusing a, because it is mutconstantsable
289+
a = c; // reusing a, because it is mutable
290290
assert_eq!(a, "abcd");
291291
}
292292

293293
#[test]
294294
fn macro_test() {
295295
macro_rules! sample_macro {
296296
// `()` indicates that the macro takes no argument.
297-
() => { 0 };
298-
($a:expr) => { $a };
299-
($a:expr, $b:expr) => { $a + $b }
300-
}
301-
assert_eq!(sample_macro!(), 0);
302-
assert_eq!(sample_macro!(1), 1);
303-
assert_eq!(sample_macro!(1, 2), 3);
297+
() => {
298+
0
299+
};
300+
($a:expr) => {
301+
$a
302+
};
303+
($a:expr, $b:expr) => {
304+
$a + $b
305+
};
306+
}
307+
assert_eq!(sample_macro!(), 0);
308+
assert_eq!(sample_macro!(1), 1);
309+
assert_eq!(sample_macro!(1, 2), 3);
304310
}
305311

306312
#[test]
307313
#[ignore]
308314
fn failing_test() {
309315
assert!(false)
310316
}
311-

0 commit comments

Comments
 (0)