From 07996ea93df72875e3c7dad41787a2a3c37c8d69 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Mon, 25 May 2020 02:51:23 -0400 Subject: [PATCH] Remove as many of the typecasts as possible in the cal command (#1886) * Remove as many of the typecasts as possible in the cal command * Run rustfmt on cal.rs --- crates/nu-cli/src/commands/cal.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/nu-cli/src/commands/cal.rs b/crates/nu-cli/src/commands/cal.rs index af9d8469..024b85fa 100644 --- a/crates/nu-cli/src/commands/cal.rs +++ b/crates/nu-cli/src/commands/cal.rs @@ -119,8 +119,8 @@ fn get_invalid_year_shell_error(year_tag: &Tag) -> ShellError { } struct MonthHelper { - day_number_month_starts_on: usize, - number_of_days_in_month: usize, + day_number_month_starts_on: u32, + number_of_days_in_month: u32, selected_year: i32, selected_month: u32, } @@ -169,8 +169,7 @@ impl MonthHelper { match naive_date_result { Ok(naive_date) => { - self.day_number_month_starts_on = - naive_date.weekday().num_days_from_sunday() as usize; + self.day_number_month_starts_on = naive_date.weekday().num_days_from_sunday(); Ok(()) } _ => Err(()), @@ -191,7 +190,7 @@ impl MonthHelper { match naive_date_result { Ok(naive_date) => { - self.number_of_days_in_month = naive_date.pred().day() as usize; + self.number_of_days_in_month = naive_date.pred().day(); Ok(()) } _ => Err(()), @@ -277,7 +276,7 @@ fn add_month_to_table( }; let day_limit = month_helper.number_of_days_in_month + month_helper.day_number_month_starts_on; - let mut day_count: usize = 1; + let mut day_count: u32 = 1; let days_of_the_week = [ "sunday",