mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
758 B
43 lines
758 B
2 years ago
|
## own_and_return
|
||
2 years ago
|
|
||
|
### Instructions
|
||
|
|
||
2 years ago
|
Create a function `only_return` that takes a `struct` Film that has one Field of type `String` and returns the string without owning it.
|
||
2 years ago
|
|
||
2 years ago
|
Create a function `own_and_return` which takes ownership of the struct, and returns the string.
|
||
2 years ago
|
|
||
|
### Expected functions
|
||
|
|
||
|
```rust
|
||
2 years ago
|
pub struct Film {
|
||
|
pub name: String,
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
pub fn only_return(your_parameter) {
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
pub fn own_and_return(your_parameter) {
|
||
|
}
|
||
|
|
||
|
|
||
2 years ago
|
```
|
||
|
|
||
|
### Usage
|
||
|
|
||
|
Here is a possible program to test your function :
|
||
|
|
||
|
```rust
|
||
2 years ago
|
use own_and_return::*;
|
||
2 years ago
|
|
||
2 years ago
|
pub struct Film {
|
||
|
pub name: String,
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
fn main() {
|
||
|
println!("{}", own_and_return(your_argument);
|
||
|
println!("{}", only_return(your_argument);
|
||
|
}
|
||
2 years ago
|
```
|
||
2 years ago
|
|
||
|
And its output should return the name of the film being passed.
|