mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 04:29:41 +00:00
remove unnecessary space
This commit is contained in:
@ -22,7 +22,7 @@ fn main() {
|
||||
|
||||
// Fix the error with at least two solutions
|
||||
fn main() {
|
||||
let s: Box<str> = "hello, world".into();
|
||||
let s: Box<str> = "hello, world".into();
|
||||
greetings(s)
|
||||
}
|
||||
|
||||
@ -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();
|
||||
@ -102,7 +102,7 @@ Opsite to the seldom using of `str`, `&str` and `String` are used everywhere!
|
||||
|
||||
// Fix error with at least two solutions
|
||||
fn main() {
|
||||
let s = "hello, world";
|
||||
let s = "hello, world";
|
||||
greetings(s)
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ fn greetings(s: String) {
|
||||
|
||||
// Use two approaches to fix the error and without adding a new line
|
||||
fn main() {
|
||||
let s = "hello, world".to_string();
|
||||
let s = "hello, world".to_string();
|
||||
let s1: &str = s;
|
||||
|
||||
println!("Success!");
|
||||
|
@ -173,7 +173,7 @@ fn main() {
|
||||
fn main() {
|
||||
let mut s = String::new();
|
||||
|
||||
let update_string = |str| s.push_str(str);
|
||||
let update_string = |str| s.push_str(str);
|
||||
|
||||
exec(update_string);
|
||||
|
||||
@ -260,7 +260,7 @@ move closures may still implement `Fn` or `FnMut`, even though they capture vari
|
||||
fn main() {
|
||||
let s = String::new();
|
||||
|
||||
let update_string = move || println!("{}",s);
|
||||
let update_string = move || println!("{}",s);
|
||||
|
||||
exec(update_string);
|
||||
}
|
||||
@ -275,7 +275,7 @@ The following code also has no error:
|
||||
fn main() {
|
||||
let s = String::new();
|
||||
|
||||
let update_string = move || println!("{}",s);
|
||||
let update_string = move || println!("{}",s);
|
||||
|
||||
exec(update_string);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ fn main() {
|
||||
|
||||
// Fill the blanks in the code to make it compile
|
||||
fn main() {
|
||||
let __ = 1;
|
||||
let __ = 1;
|
||||
__ += 2;
|
||||
|
||||
assert_eq!(x, 3);
|
||||
@ -73,7 +73,7 @@ fn main() {
|
||||
|
||||
assert_eq!(x, 12);
|
||||
|
||||
let x = 42;
|
||||
let x = 42;
|
||||
println!("{}", x); // Prints "42".
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user