Fixed the punctuations

This commit is contained in:
Tanish-Eagle 2022-08-03 11:20:50 +05:30
parent 8605ed3b8d
commit c1991f3085
1 changed files with 8 additions and 8 deletions

View File

@ -15,7 +15,7 @@ fn main() {
assert_eq!(integer, 'b' as u8); assert_eq!(integer, 'b' as u8);
println!("Success!") println!("Success!");
} }
``` ```
@ -23,17 +23,17 @@ fn main() {
```rust,editable ```rust,editable
fn main() { fn main() {
assert_eq!(u8::MAX, 255); assert_eq!(u8::MAX, 255);
// the max of `u8` is 255 as shown above. // The max of `u8` is 255 as shown above.
// so the below code will cause an overflow error: literal out of range for `u8`. // so the below code will cause an overflow error: literal out of range for `u8`.
// PLEASE looking for clues within compile errors to FIX it. // PLEASE looking for clues within compile errors to FIX it.
// DON'T modify any code in main. // DON'T modify any code in main.
let v = 1000 as u8; let v = 1000 as u8;
println!("Success!") println!("Success!");
} }
``` ```
3. 🌟🌟 when casting any value to an unsigned type `T`, `T::MAX + 1` is added or subtracted until the value fits into the new type. 3. 🌟🌟 When casting any value to an unsigned type `T`, `T::MAX + 1` is added or subtracted until the value fits into the new type.
```rust,editable ```rust,editable
fn main() { fn main() {
assert_eq!(1000 as u16, __); assert_eq!(1000 as u16, __);
@ -67,7 +67,7 @@ fn main() {
} }
``` ```
4. 🌟🌟🌟 Raw pointer can be converted to memory address (integer) and vice versa 4. 🌟🌟🌟 Raw pointers can be converted to memory address (integer) and vice versa.
```rust,editable ```rust,editable
// FILL in the blanks // FILL in the blanks
@ -78,13 +78,13 @@ fn main() {
let second_address = first_address + 4; // 4 == std::mem::size_of::<i32>() let second_address = first_address + 4; // 4 == std::mem::size_of::<i32>()
let p2: *mut i32 = second_address __; // p2 points to the 2nd element in values let p2: *mut i32 = second_address __; // p2 points to the 2nd element in values
unsafe { unsafe {
// add one to the second element // Add one to the second element
__ __
} }
assert_eq!(values[1], 3); assert_eq!(values[1], 3);
println!("Success!") println!("Success!");
} }
``` ```
@ -100,6 +100,6 @@ fn main() {
assert_eq!(std::mem::size_of_val(&*b), __) assert_eq!(std::mem::size_of_val(&*b), __)
} }
println!("Success!") println!("Success!");
} }
``` ```