according to the idea of gtm-nayan #144, add println!("Success") for each exercise

This commit is contained in:
sunface
2022-03-05 14:48:43 +08:00
parent 1000a3dc6e
commit 5394cdfcff
21 changed files with 201 additions and 13 deletions

View File

@ -12,6 +12,8 @@ fn main() {
let c2 = '中'; let c2 = '中';
assert_eq!(size_of_val(&c2),3); assert_eq!(size_of_val(&c2),3);
println!("Success!")
} }
``` ```
@ -33,13 +35,13 @@ fn print_char(c : char) {
3. 🌟 3. 🌟
```rust, editable ```rust, editable
// make the println! work // make println! work
fn main() { fn main() {
let _f: bool = false; let _f: bool = false;
let t = true; let t = true;
if !t { if !t {
println!("hello, world"); println!("Success!")
} }
} }
``` ```
@ -52,6 +54,8 @@ fn main() {
let f = true; let f = true;
let t = true && false; let t = true && false;
assert_eq!(t, f); assert_eq!(t, f);
println!("Success!")
} }
``` ```
@ -66,6 +70,8 @@ fn main() {
let v = (2, 3); let v = (2, 3);
assert_eq!(v, implicitly_ret_unit()) assert_eq!(v, implicitly_ret_unit())
println!("Success!")
} }
fn implicitly_ret_unit() { fn implicitly_ret_unit() {
@ -86,6 +92,8 @@ use std::mem::size_of_val;
fn main() { fn main() {
let unit: () = (); let unit: () = ();
assert!(size_of_val(&unit) == 4); assert!(size_of_val(&unit) == 4);
println!("Success!")
} }
``` ```

View File

@ -8,6 +8,8 @@ fn main() {
let s = sum(x, y); let s = sum(x, y);
assert_eq!(s, 3); assert_eq!(s, 3);
println!("Success!")
} }
fn sum(x, y: i32) { fn sum(x, y: i32) {
@ -24,7 +26,7 @@ fn main() {
// replace i32 with another type // replace i32 with another type
fn print() -> i32 { fn print() -> i32 {
println!("hello,world"); println!("Success!")
} }
``` ```
@ -33,8 +35,11 @@ fn print() -> i32 {
```rust,editable ```rust,editable
// solve it in two ways // solve it in two ways
// DON'T let `println!` works
fn main() { fn main() {
never_return(); never_return();
println!("Failed!")
} }
fn never_return() -> ! { fn never_return() -> ! {

View File

@ -16,6 +16,8 @@ fn main() {
y = x; y = x;
let z = 10; // type of z ? let z = 10; // type of z ?
println!("Success!")
} }
``` ```
@ -25,6 +27,8 @@ fn main() {
// fill the blank // fill the blank
fn main() { fn main() {
let v: u16 = 38_u8 as __; let v: u16 = 38_u8 as __;
println!("Success!")
} }
``` ```
@ -38,6 +42,8 @@ fn main() {
fn main() { fn main() {
let x = 5; let x = 5;
assert_eq!("u32".to_string(), type_of(&x)); 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" // 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>(_: &T) -> String {
fn main() { fn main() {
assert_eq!(i8::MAX, __); assert_eq!(i8::MAX, __);
assert_eq!(u8::MAX, __); assert_eq!(u8::MAX, __);
println!("Success!")
} }
``` ```
@ -74,6 +82,8 @@ fn main() {
fn main() { fn main() {
let v = 1_024 + 0xff + 0o77 + 0b1111_1111; let v = 1_024 + 0xff + 0o77 + 0b1111_1111;
assert!(v == 1579); assert!(v == 1579);
println!("Success!")
} }
``` ```
@ -88,6 +98,8 @@ fn main() {
let x = 1_000.000_1; // ? let x = 1_000.000_1; // ?
let y: f32 = 0.12; // f32 let y: f32 = 0.12; // f32
let z = 0.01_f64; // f64 let z = 0.01_f64; // f64
println!("Success!")
} }
``` ```
@ -97,6 +109,8 @@ fn main() {
fn main() { fn main() {
assert!(0.1+0.2==0.3); assert!(0.1+0.2==0.3);
println!("Success!")
} }
``` ```
@ -126,6 +140,8 @@ use std::ops::{Range, RangeInclusive};
fn main() { fn main() {
assert_eq!((1..__), Range{ start: 1, end: 5 }); assert_eq!((1..__), Range{ start: 1, end: 5 });
assert_eq!((1..__), RangeInclusive::new(1, 5)); assert_eq!((1..__), RangeInclusive::new(1, 5));
println!("Success!")
} }
``` ```

View File

@ -35,6 +35,8 @@ fn main() {
}; };
assert_eq!(v, 3); assert_eq!(v, 3);
println!("Success!")
} }
``` ```
@ -45,6 +47,8 @@ fn main() {
let v = (let x = 3); let v = (let x = 3);
assert!(v == 3); assert!(v == 3);
println!("Success!")
} }
``` ```
@ -54,6 +58,8 @@ fn main() {
fn main() { fn main() {
let s = sum(1 , 2); let s = sum(1 , 2);
assert_eq!(s, 3); assert_eq!(s, 3);
println!("Success!")
} }
fn sum(x: i32, y: i32) -> i32 { fn sum(x: i32, y: i32) -> i32 {

View File

@ -19,6 +19,8 @@ fn main() {
// modify below to make it work // modify below to make it work
assert!(arr.len() == 4); 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 // Arrays are stack allocated, `std::mem::size_of_val` return the bytes which array occupies
// A char takes 4 byte in Rust: Unicode char // A char takes 4 byte in Rust: Unicode char
assert!(std::mem::size_of_val(&arr) == __); assert!(std::mem::size_of_val(&arr) == __);
println!("Success!")
} }
``` ```
@ -47,6 +51,8 @@ fn main() {
assert!(list[0] == 1); assert!(list[0] == 1);
assert!(list.len() == 100); assert!(list.len() == 100);
println!("Success!")
} }
``` ```
@ -56,6 +62,8 @@ fn main() {
fn main() { fn main() {
// fix the error // fix the error
let _arr = [1, 2, '3']; 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! let ele = arr[1]; // only modify this line to make the code work!
assert!(ele == 'a'); assert!(ele == 'a');
println!("Success!")
} }
``` ```
@ -83,6 +93,8 @@ fn main() {
// but indexing is not safe // but indexing is not safe
let _name1 = &names[2]; let _name1 = &names[2];
println!("Success!")
} }
``` ```

View File

@ -28,6 +28,8 @@ fn main() {
// a enum variant can be converted to a integer by `as` // a enum variant can be converted to a integer by `as`
assert_eq!(Number::One, Number1::One); assert_eq!(Number::One, Number1::One);
assert_eq!(Number1::One, Number2::One); assert_eq!(Number1::One, Number2::One);
println!("Success!")
} }
``` ```
@ -45,6 +47,8 @@ enum Message {
fn main() { fn main() {
let msg1 = Message::Move{__}; // instantiating with x = 1, y = 2 let msg1 = Message::Move{__}; // instantiating with x = 1, y = 2
let msg2 = Message::Write(__); // instantiating with "hello, world!" let msg2 = Message::Write(__); // instantiating with "hello, world!"
println!("Success!")
} }
``` ```
@ -67,6 +71,8 @@ fn main() {
} else { } else {
panic!("NEVER LET THIS RUN"); panic!("NEVER LET THIS RUN");
} }
println!("Success!")
} }
``` ```

View File

@ -10,6 +10,8 @@ fn main() {
let s1: [i32] = arr[0..2]; let s1: [i32] = arr[0..2];
let s2: str = "hello, world" as str; let s2: str = "hello, world" as str;
println!("Success!")
} }
``` ```
@ -26,6 +28,8 @@ fn main() {
// modify '6' to make it work // 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 // 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); assert!(std::mem::size_of_val(&slice) == 6);
println!("Success!")
} }
``` ```
@ -37,6 +41,8 @@ fn main() {
// fill the blanks to make the code work // fill the blanks to make the code work
let slice: __ = __; let slice: __ = __;
assert_eq!(slice, &[2, 3, 4]); assert_eq!(slice, &[2, 3, 4]);
println!("Success!")
} }
``` ```
@ -52,6 +58,8 @@ fn main() {
let slice2 = &s[__]; let slice2 = &s[__];
assert_eq!(slice1, slice2); assert_eq!(slice1, slice2);
println!("Success!")
} }
``` ```
@ -64,6 +72,8 @@ fn main() {
let slice = &s[0..2]; let slice = &s[0..2];
assert!(slice == "你"); assert!(slice == "你");
println!("Success!")
} }
``` ```

View File

@ -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 // fix error without adding new line
fn main() { fn main() {
let s: str = "hello, world"; let s: str = "hello, world";
println!("Success!")
} }
``` ```
@ -42,6 +44,8 @@ fn main() {
s.push('!'); s.push('!');
assert_eq!(s, "hello, world!"); assert_eq!(s, "hello, world!");
println!("Success!")
} }
``` ```
@ -68,7 +72,9 @@ fn main() {
// Allocate new memory and store the modified string there // Allocate new memory and store the modified string there
let s1 = s.__("dogs", "cats"); 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() { fn main() {
let s = "hello, world".to_string(); let s = "hello, world".to_string();
let s1: &str = s; 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 let h1 = &s1[3..5];//modify this line to fix the error, tips: `` takes 3 bytes in UTF8 format
assert_eq!(h1, "中"); assert_eq!(h1, "中");
println!("Success!")
} }
``` ```

View File

@ -16,6 +16,8 @@ fn main() {
name: String::from("sunface"), name: String::from("sunface"),
age, age,
}; };
println!("Success!")
} }
``` ```
@ -34,6 +36,8 @@ impl SomeTrait for Unit { }
fn main() { fn main() {
let u = Unit; let u = Unit;
do_something_with_unit(u); do_something_with_unit(u);
println!("Success!")
} }
// fill the blank to make the code work // fill the blank to make the code work
@ -50,6 +54,8 @@ struct Point(i32, i32, i32);
fn main() { fn main() {
let v = Point(__, __, __); let v = Point(__, __, __);
check_color(v); check_color(v);
println!("Success!")
} }
fn check_color(p: Color) { fn check_color(p: Color) {
@ -83,6 +89,8 @@ fn main() {
// fill the lank // fill the lank
__ = String::from("sunfei"); __ = String::from("sunfei");
println!("Success!")
} }
``` ```
@ -94,7 +102,9 @@ struct Person {
name: String, name: String,
age: u8, age: u8,
} }
fn main() {} fn main() {
println!("Success!")
}
fn build_person(name: String, age: u8) -> Person { fn build_person(name: String, age: u8) -> Person {
Person { Person {
@ -123,6 +133,8 @@ fn main() {
}; };
let u2 = set_email(u1); let u2 = set_email(u1);
println!("Success!")
} }
fn set_email(u: User) -> User { fn set_email(u: User) -> User {

View File

@ -8,6 +8,8 @@ fn main() {
let _t1: (u8, (i16, u32)) = (0, (-1, 1)); let _t1: (u8, (i16, u32)) = (0, (-1, 1));
// fill the blanks to make the code work // fill the blanks to make the code work
let t: (u8, __, i64, __, __) = (1u8, 2u16, 3i64, "hello", String::from(", world")); let t: (u8, __, i64, __, __) = (1u8, 2u16, 3i64, "hello", String::from(", world"));
println!("Success!")
} }
``` ```
@ -18,6 +20,8 @@ fn main() {
fn main() { fn main() {
let t = ("i", "am", "sunface"); let t = ("i", "am", "sunface");
assert_eq!(t.1, "sunface"); assert_eq!(t.1, "sunface");
println!("Success!")
} }
``` ```
@ -43,6 +47,8 @@ fn main() {
assert_eq!(x, 1); assert_eq!(x, 1);
assert_eq!(y, "hello"); assert_eq!(y, "hello");
assert_eq!(z, 6.4); assert_eq!(z, 6.4);
println!("Success!")
} }
``` ```
@ -57,6 +63,8 @@ fn main() {
assert_eq!(x, 3); assert_eq!(x, 3);
assert_eq!(y, 1); assert_eq!(y, 1);
assert_eq!(z, 2); assert_eq!(z, 2);
println!("Success!")
} }
``` ```
@ -69,6 +77,8 @@ fn main() {
assert_eq!(x, 5); assert_eq!(x, 5);
assert_eq!(y, 6); assert_eq!(y, 6);
println!("Success!")
} }
fn sum_multiply(nums: (i32, i32)) -> (i32, i32) { fn sum_multiply(nums: (i32, i32)) -> (i32, i32) {

View File

@ -51,6 +51,8 @@ fn main() {
panic!("NEVER LET THIS RUN") panic!("NEVER LET THIS RUN")
} }
} }
println!("Success!")
} }
``` ```
@ -134,6 +136,8 @@ fn main() {
} }
assert_eq!(n, 66); assert_eq!(n, 66);
println!("Success!")
} }
``` ```
@ -153,6 +157,8 @@ fn main() {
} }
assert_eq!(n, 66); assert_eq!(n, 66);
println!("Success!")
} }
``` ```
@ -189,6 +195,8 @@ fn main() {
} }
assert_eq!(count, 5); assert_eq!(count, 5);
println!("Success!")
} }
``` ```
@ -208,6 +216,8 @@ fn main() {
}; };
assert_eq!(result, 20); assert_eq!(result, 20);
println!("Success!")
} }
``` ```
@ -240,7 +250,9 @@ fn main() {
} }
} }
assert!(count == __) assert!(count == __);
println!("Success!")
} }
``` ```

View File

@ -88,6 +88,8 @@ fn main() {
data: [1, 2] data: [1, 2]
} }
]; ];
println!("Success!")
} }
``` ```
@ -127,6 +129,8 @@ fn main() {
check_size(["hello你好"; __]); // size of &str ? check_size(["hello你好"; __]); // size of &str ?
check_size(["hello你好".to_string(); __]); // size of String? check_size(["hello你好".to_string(); __]); // size of String?
check_size(['中'; __]); // size of char ? check_size(['中'; __]); // size of char ?
println!("Success!")
} }

View File

@ -28,6 +28,8 @@ fn main() {
// Implicitly specified type parameter `char` to `generic()`. // Implicitly specified type parameter `char` to `generic()`.
generic(__); generic(__);
println!("Success!")
} }
``` ```
@ -41,6 +43,8 @@ fn main() {
assert_eq!(5, sum(2i8, 3i8)); assert_eq!(5, sum(2i8, 3i8));
assert_eq!(50, sum(20, 30)); assert_eq!(50, sum(20, 30));
assert_eq!(2.46, sum(1.23, 1.23)); assert_eq!(2.46, sum(1.23, 1.23));
println!("Success!")
} }
``` ```
@ -56,6 +60,8 @@ fn main() {
fn main() { fn main() {
let integer = Point { x: 5, y: 10 }; let integer = Point { x: 5, y: 10 };
let float = Point { x: 1.0, y: 4.0 }; let float = Point { x: 1.0, y: 4.0 };
println!("Success!")
} }
``` ```
@ -71,6 +77,8 @@ struct Point<T> {
fn main() { fn main() {
// DON'T modify here // DON'T modify here
let p = Point{x: 5, y : "hello".to_string()}; 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.x, 5);
assert_eq!(p3.y, '中'); assert_eq!(p3.y, '中');
println!("Success!")
} }
``` ```

View File

@ -106,6 +106,8 @@ fn main() {
let t = Teacher {}; let t = Teacher {};
assert_eq!(t.say_hi(), "Hi, I'm your new teacher"); assert_eq!(t.say_hi(), "Hi, I'm your new teacher");
assert_eq!(t.say_something(), "I'm not a bad teacher"); assert_eq!(t.say_something(), "I'm not a bad teacher");
println!("Success!")
} }
``` ```
@ -177,6 +179,8 @@ fn multipl
fn main() { fn main() {
assert_eq!(6, multiply(2u8, 3u8)); assert_eq!(6, multiply(2u8, 3u8));
assert_eq!(5.0, multiply(1.0, 5.0)); 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 // you need to derive some trait for FooBar to make it comparable
assert_eq!(Foo + Bar, FooBar); assert_eq!(Foo + Bar, FooBar);
assert_eq!(Foo - Bar, BarFoo); assert_eq!(Foo - Bar, BarFoo);
println!("Success!")
} }
``` ```
@ -456,5 +462,7 @@ fn example2() {
fn main() { fn main() {
example1(); example1();
example2(); example2();
println!("Success!")
} }
``` ```

View File

@ -132,6 +132,8 @@ fn main() {
let rect1 = Rectangle { width: 30, height: 50 }; let rect1 = Rectangle { width: 30, height: 50 };
assert_eq!(rect1.area(), 1500); assert_eq!(rect1.area(), 1500);
println!("Success!")
} }
``` ```
@ -176,7 +178,9 @@ impl TrafficLight {
self.color = "green".to_string() self.color = "green".to_string()
} }
} }
fn main() {} fn main() {
println!("Success!")
}
``` ```
@ -204,6 +208,8 @@ impl TrafficLight {
fn main() { fn main() {
let light = TrafficLight::new(); let light = TrafficLight::new();
assert_eq!(light.get_state(), "red"); assert_eq!(light.get_state(), "red");
println!("Success!")
} }
``` ```
@ -228,7 +234,9 @@ impl Rectangle {
} }
fn main() {} fn main() {
println!("Success!")
}
``` ```
### Enums ### Enums

View File

@ -22,6 +22,8 @@ fn main() {
// modify this line only // modify this line only
assert_eq!(5, y); assert_eq!(5, y);
println!("Success!")
} }
``` ```
@ -45,7 +47,9 @@ fn borrow_object(s: &String) {}
fn main() { fn main() {
let mut s = String::from("hello, "); let mut s = String::from("hello, ");
push_str(s) push_str(s);
println!("Success!")
} }
fn push_str(s: &mut String) { fn push_str(s: &mut String) {
@ -63,6 +67,8 @@ fn main() {
let p = __; let p = __;
p.push_str("world"); p.push_str("world");
println!("Success!")
} }
``` ```
@ -83,6 +89,8 @@ fn main() {
// check the equality of the two address strings // check the equality of the two address strings
assert_eq!(get_addr(r1),get_addr(r2)); assert_eq!(get_addr(r1),get_addr(r2));
println!("Success!")
} }
// get memory address string // get memory address string
@ -104,6 +112,8 @@ fn main() {
let r2 = &mut s; let r2 = &mut s;
println!("{}, {}", r1, r2); println!("{}, {}", r1, r2);
println!("Success!")
} }
``` ```
@ -116,6 +126,8 @@ fn main() {
let s = String::from("hello, "); let s = String::from("hello, ");
borrow_object(&mut s) borrow_object(&mut s)
println!("Success!")
} }
fn borrow_object(s: &mut String) {} fn borrow_object(s: &mut String) {}
@ -131,6 +143,8 @@ fn main() {
borrow_object(&s); borrow_object(&s);
s.push_str("world"); s.push_str("world");
println!("Success!")
} }
fn borrow_object(s: &String) {} fn borrow_object(s: &String) {}

View File

@ -84,6 +84,8 @@ fn main() {
let s1 = s; let s1 = s;
s1.push_str("world") s1.push_str("world")
println!("Success!")
} }
``` ```
@ -98,6 +100,8 @@ fn main() {
*y = 4; *y = 4;
assert_eq!(*x, 5); assert_eq!(*x, 5);
println!("Success!")
} }
``` ```

View File

@ -37,6 +37,8 @@ fn main() {
let binary = __; let binary = __;
assert_eq!(binary, 1); assert_eq!(binary, 1);
println!("Success!")
} }
``` ```
@ -61,6 +63,8 @@ fn main() {
for msg in msgs { for msg in msgs {
show_message(msg) show_message(msg)
} }
println!("Success!")
} }
fn show_message(msg: Message) { fn show_message(msg: Message) {
@ -91,6 +95,8 @@ fn main() {
for ab in alphabets { for ab in alphabets {
assert!(__) assert!(__)
} }
println!("Success!")
} }
``` ```
@ -113,6 +119,8 @@ fn main() {
} }
assert_eq!(count, 2); assert_eq!(count, 2);
println!("Success!")
} }
``` ```
@ -129,6 +137,8 @@ fn main() {
match o { match o {
Some(i) => { Some(i) => {
println!("This is a really long string and `{:?}`", 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!("foobar holds the value: {}", i);
println!("Success!")
} }
} }
``` ```

View File

@ -78,6 +78,8 @@ fn main() {
Some(x) => assert!(x >= split), Some(x) => assert!(x >= split),
None => (), None => (),
} }
println!("Success!")
} }
``` ```
@ -94,6 +96,8 @@ fn main() {
assert_eq!(last, 2048); assert_eq!(last, 2048);
} }
} }
println!("Success!")
} }
``` ```

View File

@ -8,7 +8,9 @@
fn main() { fn main() {
let x: i32; // uninitialized but using, ERROR ! let x: i32; // uninitialized but using, ERROR !
let y: i32; // uninitialized but also unusing, only warning 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; let __ = 1;
__ += 2; __ += 2;
println!("{} is equal to 3", x); assert_eq!(x, 3);
println!("Success!")
} }
``` ```
@ -90,6 +93,8 @@ fn main() {
let y = 4; let y = 4;
// shadowing // shadowing
let y = "I can also be bound to text!"; let y = "I can also be bound to text!";
println!("Success!")
} }
``` ```
@ -124,6 +129,8 @@ fn main() {
assert_eq!(x, 3); assert_eq!(x, 3);
assert_eq!(y, 2); assert_eq!(y, 2);
println!("Success!")
} }
``` ```
@ -142,6 +149,8 @@ fn main() {
[.., y] = [1, 2]; [.., y] = [1, 2];
// fill the blank to make the code work // fill the blank to make the code work
assert_eq!([x,y], __); assert_eq!([x,y], __);
println!("Success!")
} }
``` ```

View File

@ -11,6 +11,8 @@ fn main() {
let c2 = '中'; let c2 = '中';
assert_eq!(size_of_val(&c2),3); assert_eq!(size_of_val(&c2),3);
println!("Success!")
} }
``` ```
@ -31,13 +33,13 @@ fn print_char(c : char) {
3. 🌟 3. 🌟
```rust, editable ```rust, editable
// println! 工作 // make println! work
fn main() { fn main() {
let _f: bool = false; let _f: bool = false;
let t = true; let t = true;
if !t { if !t {
println!("hello, world"); println!("Success!")
} }
} }
``` ```
@ -49,6 +51,8 @@ fn main() {
let f = true; let f = true;
let t = true && false; let t = true && false;
assert_eq!(t, f); assert_eq!(t, f);
println!("Success!")
} }
``` ```
@ -63,6 +67,8 @@ fn main() {
let v = (2, 3); let v = (2, 3);
assert_eq!(v, implicitly_ret_unit()) assert_eq!(v, implicitly_ret_unit())
println!("Success!")
} }
fn implicitly_ret_unit() { fn implicitly_ret_unit() {
@ -83,6 +89,8 @@ use std::mem::size_of_val;
fn main() { fn main() {
let unit: () = (); let unit: () = ();
assert!(size_of_val(&unit) == 4); assert!(size_of_val(&unit) == 4);
println!("Success!")
} }
``` ```