mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 20:49:41 +00:00
Merge pull request #301 from ChloroplastYu/patch-1
Solution: add a new solution for ownership-4
This commit is contained in:
@ -96,6 +96,17 @@ fn print_str(s: String) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```rust
|
||||||
|
fn main() {
|
||||||
|
let s = String::from("hello, world");
|
||||||
|
print_str(&s);
|
||||||
|
println!("{}", s);
|
||||||
|
}
|
||||||
|
fn print_str(s: &String) {
|
||||||
|
println!("{}",s)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
5.
|
5.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
Reference in New Issue
Block a user