diff --git a/src/basic-types/char-bool-unit.md b/src/basic-types/char-bool-unit.md index 98f104c..67462e8 100644 --- a/src/basic-types/char-bool-unit.md +++ b/src/basic-types/char-bool-unit.md @@ -12,6 +12,8 @@ fn main() { let c2 = '中'; assert_eq!(size_of_val(&c2),3); + + println!("Success!") } ``` @@ -33,13 +35,13 @@ fn print_char(c : char) { 3. 🌟 ```rust, editable -// make the println! work +// make println! work fn main() { let _f: bool = false; let t = true; if !t { - println!("hello, world"); + println!("Success!") } } ``` @@ -52,6 +54,8 @@ fn main() { let f = true; let t = true && false; assert_eq!(t, f); + + println!("Success!") } ``` @@ -66,6 +70,8 @@ fn main() { let v = (2, 3); assert_eq!(v, implicitly_ret_unit()) + + println!("Success!") } fn implicitly_ret_unit() { @@ -86,6 +92,8 @@ use std::mem::size_of_val; fn main() { let unit: () = (); assert!(size_of_val(&unit) == 4); + + println!("Success!") } ``` diff --git a/src/basic-types/functions.md b/src/basic-types/functions.md index bab0197..e3cb022 100644 --- a/src/basic-types/functions.md +++ b/src/basic-types/functions.md @@ -8,6 +8,8 @@ fn main() { let s = sum(x, y); assert_eq!(s, 3); + + println!("Success!") } fn sum(x, y: i32) { @@ -24,7 +26,7 @@ fn main() { // replace i32 with another type fn print() -> i32 { - println!("hello,world"); + println!("Success!") } ``` @@ -33,8 +35,11 @@ fn print() -> i32 { ```rust,editable // solve it in two ways +// DON'T let `println!` works fn main() { never_return(); + + println!("Failed!") } fn never_return() -> ! { diff --git a/src/basic-types/numbers.md b/src/basic-types/numbers.md index 915a461..d0ccbbb 100644 --- a/src/basic-types/numbers.md +++ b/src/basic-types/numbers.md @@ -16,6 +16,8 @@ fn main() { y = x; let z = 10; // type of z ? + + println!("Success!") } ``` @@ -25,6 +27,8 @@ fn main() { // fill the blank fn main() { let v: u16 = 38_u8 as __; + + println!("Success!") } ``` @@ -38,6 +42,8 @@ fn main() { fn main() { let x = 5; assert_eq!("u32".to_string(), type_of(&x)); + + println!("Success!") } // get the type of given variable, return a string representation of the type , e.g "i8", "u8", "i32", "u32" @@ -53,6 +59,8 @@ fn type_of(_: &T) -> String { fn main() { assert_eq!(i8::MAX, __); assert_eq!(u8::MAX, __); + + println!("Success!") } ``` @@ -74,6 +82,8 @@ fn main() { fn main() { let v = 1_024 + 0xff + 0o77 + 0b1111_1111; assert!(v == 1579); + + println!("Success!") } ``` @@ -88,6 +98,8 @@ fn main() { let x = 1_000.000_1; // ? let y: f32 = 0.12; // f32 let z = 0.01_f64; // f64 + + println!("Success!") } ``` @@ -97,6 +109,8 @@ fn main() { fn main() { assert!(0.1+0.2==0.3); + + println!("Success!") } ``` @@ -126,6 +140,8 @@ use std::ops::{Range, RangeInclusive}; fn main() { assert_eq!((1..__), Range{ start: 1, end: 5 }); assert_eq!((1..__), RangeInclusive::new(1, 5)); + + println!("Success!") } ``` diff --git a/src/basic-types/statements-expressions.md b/src/basic-types/statements-expressions.md index c144912..0d8f022 100644 --- a/src/basic-types/statements-expressions.md +++ b/src/basic-types/statements-expressions.md @@ -35,6 +35,8 @@ fn main() { }; assert_eq!(v, 3); + + println!("Success!") } ``` @@ -45,6 +47,8 @@ fn main() { let v = (let x = 3); assert!(v == 3); + + println!("Success!") } ``` @@ -54,6 +58,8 @@ fn main() { fn main() { let s = sum(1 , 2); assert_eq!(s, 3); + + println!("Success!") } fn sum(x: i32, y: i32) -> i32 { diff --git a/src/compound-types/array.md b/src/compound-types/array.md index 321fe6c..92104e1 100644 --- a/src/compound-types/array.md +++ b/src/compound-types/array.md @@ -19,6 +19,8 @@ fn main() { // modify below to make it work assert!(arr.len() == 4); + + println!("Success!") } ``` @@ -34,6 +36,8 @@ fn main() { // Arrays are stack allocated, `std::mem::size_of_val` return the bytes which array occupies // A char takes 4 byte in Rust: Unicode char assert!(std::mem::size_of_val(&arr) == __); + + println!("Success!") } ``` @@ -47,6 +51,8 @@ fn main() { assert!(list[0] == 1); assert!(list.len() == 100); + + println!("Success!") } ``` @@ -56,6 +62,8 @@ fn main() { fn main() { // fix the error let _arr = [1, 2, '3']; + + println!("Success!") } ``` @@ -68,6 +76,8 @@ fn main() { let ele = arr[1]; // only modify this line to make the code work! assert!(ele == 'a'); + + println!("Success!") } ``` @@ -83,6 +93,8 @@ fn main() { // but indexing is not safe let _name1 = &names[2]; + + println!("Success!") } ``` diff --git a/src/compound-types/enum.md b/src/compound-types/enum.md index 092492f..2fba9cf 100644 --- a/src/compound-types/enum.md +++ b/src/compound-types/enum.md @@ -28,6 +28,8 @@ fn main() { // a enum variant can be converted to a integer by `as` assert_eq!(Number::One, Number1::One); assert_eq!(Number1::One, Number2::One); + + println!("Success!") } ``` @@ -45,6 +47,8 @@ enum Message { fn main() { let msg1 = Message::Move{__}; // instantiating with x = 1, y = 2 let msg2 = Message::Write(__); // instantiating with "hello, world!" + + println!("Success!") } ``` @@ -67,6 +71,8 @@ fn main() { } else { panic!("NEVER LET THIS RUN!"); } + + println!("Success!") } ``` diff --git a/src/compound-types/slice.md b/src/compound-types/slice.md index 85ad192..2c4c0ec 100644 --- a/src/compound-types/slice.md +++ b/src/compound-types/slice.md @@ -10,6 +10,8 @@ fn main() { let s1: [i32] = arr[0..2]; let s2: str = "hello, world" as str; + + println!("Success!") } ``` @@ -26,6 +28,8 @@ fn main() { // modify '6' to make it work // TIPS: slice( reference ) IS NOT an array, if it is an array, then `assert!` will passed: each of the two UTF-8 chars '中' and '国' occupies 3 bytes, 2 * 3 = 6 assert!(std::mem::size_of_val(&slice) == 6); + + println!("Success!") } ``` @@ -37,6 +41,8 @@ fn main() { // fill the blanks to make the code work let slice: __ = __; assert_eq!(slice, &[2, 3, 4]); + + println!("Success!") } ``` @@ -52,6 +58,8 @@ fn main() { let slice2 = &s[__]; assert_eq!(slice1, slice2); + + println!("Success!") } ``` @@ -64,6 +72,8 @@ fn main() { let slice = &s[0..2]; assert!(slice == "你"); + + println!("Success!") } ``` diff --git a/src/compound-types/string.md b/src/compound-types/string.md index fdb29bb..76bfc1f 100644 --- a/src/compound-types/string.md +++ b/src/compound-types/string.md @@ -10,6 +10,8 @@ The type of string literal `"hello, world"` is `&str`, e.g `let s: &str = "hello // fix error without adding new line fn main() { let s: str = "hello, world"; + + println!("Success!") } ``` @@ -42,6 +44,8 @@ fn main() { s.push('!'); assert_eq!(s, "hello, world!"); + + println!("Success!") } ``` @@ -68,7 +72,9 @@ fn main() { // Allocate new memory and store the modified string there let s1 = s.__("dogs", "cats"); - assert_eq!(s1, "I like cats") + assert_eq!(s1, "I like cats"); + + println!("Success!") } ``` @@ -113,6 +119,8 @@ fn greetings(s: String) { fn main() { let s = "hello, world".to_string(); let s1: &str = s; + + println!("Success!") } ``` @@ -222,6 +230,8 @@ fn main() { let h1 = &s1[3..5];//modify this line to fix the error, tips: `中` takes 3 bytes in UTF8 format assert_eq!(h1, "中"); + + println!("Success!") } ``` diff --git a/src/compound-types/struct.md b/src/compound-types/struct.md index 7061f44..00dece8 100644 --- a/src/compound-types/struct.md +++ b/src/compound-types/struct.md @@ -16,6 +16,8 @@ fn main() { name: String::from("sunface"), age, }; + + println!("Success!") } ``` @@ -34,6 +36,8 @@ impl SomeTrait for Unit { } fn main() { let u = Unit; do_something_with_unit(u); + + println!("Success!") } // fill the blank to make the code work @@ -50,6 +54,8 @@ struct Point(i32, i32, i32); fn main() { let v = Point(__, __, __); check_color(v); + + println!("Success!") } fn check_color(p: Color) { @@ -83,6 +89,8 @@ fn main() { // fill the lank __ = String::from("sunfei"); + + println!("Success!") } ``` @@ -94,7 +102,9 @@ struct Person { name: String, age: u8, } -fn main() {} +fn main() { + println!("Success!") +} fn build_person(name: String, age: u8) -> Person { Person { @@ -123,6 +133,8 @@ fn main() { }; let u2 = set_email(u1); + + println!("Success!") } fn set_email(u: User) -> User { diff --git a/src/compound-types/tuple.md b/src/compound-types/tuple.md index df793a5..3912eb6 100644 --- a/src/compound-types/tuple.md +++ b/src/compound-types/tuple.md @@ -8,6 +8,8 @@ fn main() { let _t1: (u8, (i16, u32)) = (0, (-1, 1)); // fill the blanks to make the code work let t: (u8, __, i64, __, __) = (1u8, 2u16, 3i64, "hello", String::from(", world")); + + println!("Success!") } ``` @@ -18,6 +20,8 @@ fn main() { fn main() { let t = ("i", "am", "sunface"); assert_eq!(t.1, "sunface"); + + println!("Success!") } ``` @@ -43,6 +47,8 @@ fn main() { assert_eq!(x, 1); assert_eq!(y, "hello"); assert_eq!(z, 6.4); + + println!("Success!") } ``` @@ -57,6 +63,8 @@ fn main() { assert_eq!(x, 3); assert_eq!(y, 1); assert_eq!(z, 2); + + println!("Success!") } ``` @@ -69,6 +77,8 @@ fn main() { assert_eq!(x, 5); assert_eq!(y, 6); + + println!("Success!") } fn sum_multiply(nums: (i32, i32)) -> (i32, i32) { diff --git a/src/flow-control.md b/src/flow-control.md index 33b2bfb..ac19d87 100644 --- a/src/flow-control.md +++ b/src/flow-control.md @@ -51,6 +51,8 @@ fn main() { panic!("NEVER LET THIS RUN") } } + + println!("Success!") } ``` @@ -134,6 +136,8 @@ fn main() { } assert_eq!(n, 66); + + println!("Success!") } ``` @@ -153,6 +157,8 @@ fn main() { } assert_eq!(n, 66); + + println!("Success!") } ``` @@ -189,6 +195,8 @@ fn main() { } assert_eq!(count, 5); + + println!("Success!") } ``` @@ -208,6 +216,8 @@ fn main() { }; assert_eq!(result, 20); + + println!("Success!") } ``` @@ -240,7 +250,9 @@ fn main() { } } - assert!(count == __) + assert!(count == __); + + println!("Success!") } ``` diff --git a/src/generics-traits/const-generics.md b/src/generics-traits/const-generics.md index 45b8a95..90605ee 100644 --- a/src/generics-traits/const-generics.md +++ b/src/generics-traits/const-generics.md @@ -88,6 +88,8 @@ fn main() { data: [1, 2] } ]; + + println!("Success!") } ``` @@ -127,6 +129,8 @@ fn main() { check_size(["hello你好"; __]); // size of &str ? check_size(["hello你好".to_string(); __]); // size of String? check_size(['中'; __]); // size of char ? + + println!("Success!") } diff --git a/src/generics-traits/generics.md b/src/generics-traits/generics.md index 1896f48..dce2a14 100644 --- a/src/generics-traits/generics.md +++ b/src/generics-traits/generics.md @@ -28,6 +28,8 @@ fn main() { // Implicitly specified type parameter `char` to `generic()`. generic(__); + + println!("Success!") } ``` @@ -41,6 +43,8 @@ fn main() { assert_eq!(5, sum(2i8, 3i8)); assert_eq!(50, sum(20, 30)); assert_eq!(2.46, sum(1.23, 1.23)); + + println!("Success!") } ``` @@ -56,6 +60,8 @@ fn main() { fn main() { let integer = Point { x: 5, y: 10 }; let float = Point { x: 1.0, y: 4.0 }; + + println!("Success!") } ``` @@ -71,6 +77,8 @@ struct Point { fn main() { // DON'T modify here let p = Point{x: 5, y : "hello".to_string()}; + + println!("Success!") } ``` @@ -118,6 +126,8 @@ fn main() { assert_eq!(p3.x, 5); assert_eq!(p3.y, '中'); + + println!("Success!") } ``` diff --git a/src/generics-traits/traits.md b/src/generics-traits/traits.md index b074453..c0b1e9c 100644 --- a/src/generics-traits/traits.md +++ b/src/generics-traits/traits.md @@ -106,6 +106,8 @@ fn main() { let t = Teacher {}; assert_eq!(t.say_hi(), "Hi, I'm your new teacher"); assert_eq!(t.say_something(), "I'm not a bad teacher"); + + println!("Success!") } ``` @@ -177,6 +179,8 @@ fn multipl fn main() { assert_eq!(6, multiply(2u8, 3u8)); assert_eq!(5.0, multiply(1.0, 5.0)); + + println!("Success!") } ``` @@ -217,6 +221,8 @@ fn main() { // you need to derive some trait for FooBar to make it comparable assert_eq!(Foo + Bar, FooBar); assert_eq!(Foo - Bar, BarFoo); + + println!("Success!") } ``` @@ -456,5 +462,7 @@ fn example2() { fn main() { example1(); example2(); + + println!("Success!") } ``` \ No newline at end of file diff --git a/src/method.md b/src/method.md index 6f7d977..477ddcc 100644 --- a/src/method.md +++ b/src/method.md @@ -132,6 +132,8 @@ fn main() { let rect1 = Rectangle { width: 30, height: 50 }; assert_eq!(rect1.area(), 1500); + + println!("Success!") } ``` @@ -176,7 +178,9 @@ impl TrafficLight { self.color = "green".to_string() } } -fn main() {} +fn main() { + println!("Success!") +} ``` @@ -204,6 +208,8 @@ impl TrafficLight { fn main() { let light = TrafficLight::new(); assert_eq!(light.get_state(), "red"); + + println!("Success!") } ``` @@ -228,7 +234,9 @@ impl Rectangle { } -fn main() {} +fn main() { + println!("Success!") +} ``` ### Enums diff --git a/src/ownership/borrowing.md b/src/ownership/borrowing.md index 1d5b87c..e5a2903 100644 --- a/src/ownership/borrowing.md +++ b/src/ownership/borrowing.md @@ -22,6 +22,8 @@ fn main() { // modify this line only assert_eq!(5, y); + + println!("Success!") } ``` @@ -45,7 +47,9 @@ fn borrow_object(s: &String) {} fn main() { let mut s = String::from("hello, "); - push_str(s) + push_str(s); + + println!("Success!") } fn push_str(s: &mut String) { @@ -63,6 +67,8 @@ fn main() { let p = __; p.push_str("world"); + + println!("Success!") } ``` @@ -83,6 +89,8 @@ fn main() { // check the equality of the two address strings assert_eq!(get_addr(r1),get_addr(r2)); + + println!("Success!") } // get memory address string @@ -104,6 +112,8 @@ fn main() { let r2 = &mut s; println!("{}, {}", r1, r2); + + println!("Success!") } ``` @@ -116,6 +126,8 @@ fn main() { let s = String::from("hello, "); borrow_object(&mut s) + + println!("Success!") } fn borrow_object(s: &mut String) {} @@ -131,6 +143,8 @@ fn main() { borrow_object(&s); s.push_str("world"); + + println!("Success!") } fn borrow_object(s: &String) {} diff --git a/src/ownership/ownership.md b/src/ownership/ownership.md index af3d881..7bfac60 100644 --- a/src/ownership/ownership.md +++ b/src/ownership/ownership.md @@ -84,6 +84,8 @@ fn main() { let s1 = s; s1.push_str("world") + + println!("Success!") } ``` @@ -98,6 +100,8 @@ fn main() { *y = 4; assert_eq!(*x, 5); + + println!("Success!") } ``` diff --git a/src/pattern-match/match-iflet.md b/src/pattern-match/match-iflet.md index 2ed54eb..e4c3c3f 100644 --- a/src/pattern-match/match-iflet.md +++ b/src/pattern-match/match-iflet.md @@ -37,6 +37,8 @@ fn main() { let binary = __; assert_eq!(binary, 1); + + println!("Success!") } ``` @@ -61,6 +63,8 @@ fn main() { for msg in msgs { show_message(msg) } + + println!("Success!") } fn show_message(msg: Message) { @@ -91,6 +95,8 @@ fn main() { for ab in alphabets { assert!(__) } + + println!("Success!") } ``` @@ -113,6 +119,8 @@ fn main() { } assert_eq!(count, 2); + + println!("Success!") } ``` @@ -129,6 +137,8 @@ fn main() { match o { Some(i) => { println!("This is a really long string and `{:?}`", i); + + println!("Success!") } _ => {} }; @@ -148,6 +158,8 @@ fn main() { __ { println!("foobar holds the value: {}", i); + + println!("Success!") } } ``` diff --git a/src/pattern-match/patterns.md b/src/pattern-match/patterns.md index bf65bd8..d438705 100644 --- a/src/pattern-match/patterns.md +++ b/src/pattern-match/patterns.md @@ -78,6 +78,8 @@ fn main() { Some(x) => assert!(x >= split), None => (), } + + println!("Success!") } ``` @@ -94,6 +96,8 @@ fn main() { assert_eq!(last, 2048); } } + + println!("Success!") } ``` diff --git a/src/variables.md b/src/variables.md index c977e43..43ad6c5 100644 --- a/src/variables.md +++ b/src/variables.md @@ -8,7 +8,9 @@ fn main() { let x: i32; // uninitialized but using, ERROR ! let y: i32; // uninitialized but also unusing, only warning - println!("{} is equal to 5", x); + + assert_eq!(x, 5); + println!("Success!") } ``` @@ -20,7 +22,8 @@ fn main() { let __ = 1; __ += 2; - println!("{} is equal to 3", x); + assert_eq!(x, 3); + println!("Success!") } ``` @@ -90,6 +93,8 @@ fn main() { let y = 4; // shadowing let y = "I can also be bound to text!"; + + println!("Success!") } ``` @@ -124,6 +129,8 @@ fn main() { assert_eq!(x, 3); assert_eq!(y, 2); + + println!("Success!") } ``` @@ -142,6 +149,8 @@ fn main() { [.., y] = [1, 2]; // fill the blank to make the code work assert_eq!([x,y], __); + + println!("Success!") } ``` diff --git a/zh-CN/src/basic-types/char-bool-unit.md b/zh-CN/src/basic-types/char-bool-unit.md index 9437bda..8b90ff9 100644 --- a/zh-CN/src/basic-types/char-bool-unit.md +++ b/zh-CN/src/basic-types/char-bool-unit.md @@ -11,6 +11,8 @@ fn main() { let c2 = '中'; assert_eq!(size_of_val(&c2),3); + + println!("Success!") } ``` @@ -31,13 +33,13 @@ fn print_char(c : char) { 3. 🌟 ```rust, editable -// 让 println! 工作 +// make println! work fn main() { let _f: bool = false; let t = true; if !t { - println!("hello, world"); + println!("Success!") } } ``` @@ -49,6 +51,8 @@ fn main() { let f = true; let t = true && false; assert_eq!(t, f); + + println!("Success!") } ``` @@ -63,6 +67,8 @@ fn main() { let v = (2, 3); assert_eq!(v, implicitly_ret_unit()) + + println!("Success!") } fn implicitly_ret_unit() { @@ -83,6 +89,8 @@ use std::mem::size_of_val; fn main() { let unit: () = (); assert!(size_of_val(&unit) == 4); + + println!("Success!") } ```