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.
33 lines
496 B
33 lines
496 B
4 years ago
|
## generics
|
||
|
|
||
|
### Instructions
|
||
|
|
||
|
Write a functions called identity that calculates the identity of a value (receives any data type and returns the same value)
|
||
|
|
||
|
### Expected Function
|
||
|
|
||
|
```rust
|
||
|
fn identity(v: _) -> _ {
|
||
|
}
|
||
|
```
|
||
|
|
||
|
### Usage
|
||
|
|
||
|
Here is a program to test your function.
|
||
|
|
||
|
```rust
|
||
|
fn main() {
|
||
|
println!("{}", identity("Hello, world!"));
|
||
|
println!("{}", identity(3));
|
||
|
}
|
||
|
```
|
||
|
|
||
|
And its output
|
||
|
|
||
|
```console
|
||
|
student@ubuntu:~/[[ROOT]]/test$ cargo run
|
||
|
Hello, world!
|
||
|
3
|
||
|
student@ubuntu:~/[[ROOT]]/test$
|
||
|
```
|