From 59e8f70e55fdcb5d8dcda651254f52cfdd76ce1f Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 12 Jul 2024 18:31:23 +0200 Subject: [PATCH] Format code --- exercises/14_generics/generics3.rs | 18 +++++++++--------- solutions/14_generics/generics3.rs | 16 +++++++++------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/exercises/14_generics/generics3.rs b/exercises/14_generics/generics3.rs index 662d1b96..a60b396a 100644 --- a/exercises/14_generics/generics3.rs +++ b/exercises/14_generics/generics3.rs @@ -4,10 +4,7 @@ // This function should take an array of `Option` elements and returns array of not None elements // TODO fix this function signature fn into_dispose_nulls(list: Vec>) -> Vec<&str> { - list - .into_iter() - .flatten() - .collect() + list.into_iter().flatten().collect() } fn main() { @@ -37,7 +34,7 @@ mod tests { #[allow(dead_code)] struct Rectangle { width: i32, - height: i32 + height: i32, } impl Rectangle { fn new(width: i32, height: i32) -> Self { @@ -45,10 +42,13 @@ mod tests { } } - let custom_list = vec![Some(Rectangle::new(1, 2)), None, None, Some(Rectangle::new(3, 4))]; + let custom_list = vec![ + Some(Rectangle::new(1, 2)), + None, + None, + Some(Rectangle::new(3, 4)), + ]; let only_values = into_dispose_nulls(custom_list); assert_eq!(only_values.len(), 2); } - - -} \ No newline at end of file +} diff --git a/solutions/14_generics/generics3.rs b/solutions/14_generics/generics3.rs index 73046993..8c137ec1 100644 --- a/solutions/14_generics/generics3.rs +++ b/solutions/14_generics/generics3.rs @@ -4,10 +4,7 @@ // Here we added generic type `T` to function signature // Now this function can be used with vector of any fn into_dispose_nulls(list: Vec>) -> Vec { - list - .into_iter() - .flatten() - .collect() + list.into_iter().flatten().collect() } fn main() { @@ -36,7 +33,7 @@ mod tests { fn store_custom_type_on_list() { struct Rectangle { width: i32, - height: i32 + height: i32, } impl Rectangle { fn new(width: i32, height: i32) -> Self { @@ -44,8 +41,13 @@ mod tests { } } - let custom_list = vec![Some(Rectangle::new(1, 2)), None, None, Some(Rectangle::new(3, 4))]; + let custom_list = vec![ + Some(Rectangle::new(1, 2)), + None, + None, + Some(Rectangle::new(3, 4)), + ]; let only_values = into_dispose_nulls(custom_list); assert_eq!(only_values.len(), 2); } -} \ No newline at end of file +}