From 8329fff047d97e89ace82f99fd42684bc0dc25d5 Mon Sep 17 00:00:00 2001 From: RyuuSleek <74394241+RyuuSleek@users.noreply.github.com> Date: Sun, 13 Nov 2022 04:55:57 +0000 Subject: [PATCH 1/3] fixed some formatting --- en/src/compound-types/string.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/en/src/compound-types/string.md b/en/src/compound-types/string.md index 627ce5e..4a1d135 100644 --- a/en/src/compound-types/string.md +++ b/en/src/compound-types/string.md @@ -54,7 +54,7 @@ fn main() { // Fix all errors without adding newline fn main() { - let s = String::from("hello"); + let s = String::from("hello"); s.push(','); s.push(" world"); s += "!".to_string(); @@ -89,8 +89,8 @@ fn main() { let s1 = String::from("hello,"); let s2 = String::from("world!"); let s3 = s1 + s2; - assert_eq!(s3,"hello,world!"); - println!("{}",s1); + assert_eq!(s3, "hello,world!"); + println!("{}", s1); } ``` @@ -107,7 +107,7 @@ fn main() { } fn greetings(s: String) { - println!("{}",s) + println!("{}", s) } ``` @@ -140,7 +140,7 @@ fn main() { println!("Unicode character {} (U+211D) is called {}", unicode_codepoint, character_name ); - let long_string = "String literals + let long_string = "String literals can span multiple lines. The linebreak and indentation here \ can be escaped too!"; @@ -163,7 +163,7 @@ fn main() { // If you need "# in your string, just use more #s in the delimiter. // You can use up to 65535 #s. - let delimiter = r###"A string with "# in it. And even "##!"###; + let delimiter = r###"A string with "# in it. And even "##!"###; println!("{}", delimiter); let long_delimiter = __; @@ -262,4 +262,4 @@ fn main() { } ``` -> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it From 8398d28e7bcc7e36bcd8144c74f0e5b7d7e3fcdd Mon Sep 17 00:00:00 2001 From: RyuuSleek <74394241+RyuuSleek@users.noreply.github.com> Date: Mon, 14 Nov 2022 04:20:19 +0000 Subject: [PATCH 2/3] Fix: typo --- en/src/compound-types/string.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/src/compound-types/string.md b/en/src/compound-types/string.md index 4a1d135..993bd39 100644 --- a/en/src/compound-types/string.md +++ b/en/src/compound-types/string.md @@ -95,7 +95,7 @@ fn main() { ``` ### &str and String -Opsite to the seldom using of `str`, `&str` and `String` are used everywhere! +Opposite to the seldom using of `str`, `&str` and `String` are used everywhere! 7. 🌟🌟 `&str` can be converted to `String` in two ways ```rust,editable From 58f37692ad082da253d4bf3735301673df26f268 Mon Sep 17 00:00:00 2001 From: RyuuSleek <74394241+RyuuSleek@users.noreply.github.com> Date: Mon, 14 Nov 2022 05:09:39 +0000 Subject: [PATCH 3/3] Punctuation and grammar changes I believe the implicit conversions of references is called "Deref coercion". --- en/src/compound-types/slice.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/en/src/compound-types/slice.md b/en/src/compound-types/slice.md index 5fe1e65..53f981f 100644 --- a/en/src/compound-types/slice.md +++ b/en/src/compound-types/slice.md @@ -15,7 +15,7 @@ fn main() { } ``` -A slice reference is a two-word object, for simplicity reasons, from now on we will use slice instead of `slice reference`. The first word is a pointer to the data, and the second word is the length of the slice. The word size is the same as usize, determined by the processor architecture, eg 64 bits on an x86-64. Slices can be used to borrow a section of an array, and have the type signature `&[T]`. +A slice reference is a two-word object, for simplicity reasons, from now on we will use slice instead of `slice reference`. The first word is a pointer to the data, and the second word is the length of the slice. The word size is the same as usize, determined by the processor architecture, e.g. 64 bits on an x86-64. Slices can be used to borrow a section of an array, and have the type signature `&[T]`. 2. 🌟🌟🌟 ```rust,editable @@ -26,7 +26,7 @@ fn main() { let slice = &arr[..2]; // Modify '8' to make it work - // TIPS: slice( reference ) IS NOT an array, if it is an array, then `assert!` will passed: Each of the two chars 'δΈ­' and 'ε›½' occupies 4 bytes, 2 * 4 = 8 + // TIPS: slice( reference ) IS NOT an array, if it is an array, then `assert!` will be passed: Each of the two chars 'δΈ­' and 'ε›½' occupies 4 bytes, 2 * 4 = 8 assert!(std::mem::size_of_val(&slice) == 8); println!("Success!"); @@ -85,7 +85,7 @@ fn main() { let mut s = String::from("hello world"); // Here, &s is `&String` type, but `first_word` need a `&str` type. - // It works because `&String` can be implicitly converted to `&str, If you want know more ,this is called `Deref` + // It works because `&String` can be implicitly converted to `&str. If you want know more, this is called `Deref coercion`. let word = first_word(&s); s.clear(); // error! @@ -97,4 +97,4 @@ fn first_word(s: &str) -> &str { } ``` -> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it