mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-07 19:29:18 +00:00
✨ 🦀 Generics Solved
This commit is contained in:
parent
da5b91c999
commit
34bf2e7398
@ -3,9 +3,7 @@
|
||||
|
||||
// Execute `rustlings hint generics1` or use the `hint` watch subcommand for a hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
fn main() {
|
||||
let mut shopping_list: Vec<?> = Vec::new();
|
||||
shopping_list.push("milk");
|
||||
let mut shopping_list: Vec<String> = Vec::new();
|
||||
shopping_list.push("milk".to_string());
|
||||
}
|
||||
|
||||
@ -3,14 +3,12 @@
|
||||
|
||||
// Execute `rustlings hint generics2` or use the `hint` watch subcommand for a hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
struct Wrapper {
|
||||
value: u32,
|
||||
struct Wrapper<T> {
|
||||
value: T,
|
||||
}
|
||||
|
||||
impl Wrapper {
|
||||
pub fn new(value: u32) -> Self {
|
||||
impl<T> Wrapper<T> {
|
||||
pub fn new(value: T) -> Self {
|
||||
Wrapper { value }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user