mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-25 00:18:46 +08:00
Use a string literal instead of String::from
; that's not a method
We've talked about Strings vs string literals at this point. Hopefully this should be less distracting.
This commit is contained in:
parent
bfc469d83a
commit
e6443565eb
@ -4,9 +4,9 @@ In the last section on ownership, we made several references to ‘methods’.
|
||||
Methods look like this:
|
||||
|
||||
```rust
|
||||
let s1 = String::from("hello");
|
||||
let s1 = "hello";
|
||||
|
||||
// call a method on our String
|
||||
// call a method on s1
|
||||
let s2 = s1.clone();
|
||||
|
||||
println!("{}", s1);
|
||||
|
Loading…
Reference in New Issue
Block a user