제네릭 공부중

This commit is contained in:
blacktoast 2021-10-15 07:46:27 +00:00
parent 8de108505d
commit df475c65c0
4 changed files with 8 additions and 11 deletions

View File

@ -3,15 +3,14 @@
// This program uses a completed version of the code from errors4.
// It won't compile right now! Why?
// Execute `rustlings hint errors5` for hints!
// I AM NOT DONE
//못품 일단 넘기기
use std::error;
use std::fmt;
use std::num::ParseIntError;
// TODO: update the return type of `main()` to make this compile.
fn main() -> Result<(), (ParseIntError,CreationError)> {
fn main() -> Result<(),ParseIntError> {
let pretend_user_input = "42";
let x: i64 = pretend_user_input.parse()?;
println!("output={:?}", PositiveNonzeroInteger::new(x)?);

View File

@ -8,7 +8,7 @@
// Make these tests pass! Execute `rustlings hint errors6` for hints :)
// I AM NOT DONE
// 일단 넘김 패스
use std::num::ParseIntError;

View File

@ -3,9 +3,8 @@
// Execute `rustlings hint generics1` for hints!
// I AM NOT DONE
fn main() {
let mut shopping_list: Vec<?> = Vec::new();
let mut shopping_list: Vec<&str> = Vec::new();
shopping_list.push("milk");
}

View File

@ -3,14 +3,13 @@
// Execute `rustlings hint generics2` for hints!
// 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 }
}
}