[Rust] Generic : Data Type 예제 (23일차)
fn largest(list: &[T]) -> T { let mut largest = list[0]; for item in list.iter() { if item > largest { largest = item; } } largest } fn main() { let numbers = vec![34, 50, 25, 100, 65]; let result = largest(&numbers); println!("The largest number is {}", result); let chars = vec!['y', 'm', 'a', 'q']; let result = largest(&chars); println!("The largest char is {}", result); } struct Point { x: T,..
2023. 1. 5.