mirror of
https://github.com/nushell/nushell.git
synced 2025-04-26 14:18:19 +02:00
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
This commit is contained in:
parent
c71510c65c
commit
07996ea93d
@ -119,8 +119,8 @@ fn get_invalid_year_shell_error(year_tag: &Tag) -> ShellError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct MonthHelper {
|
struct MonthHelper {
|
||||||
day_number_month_starts_on: usize,
|
day_number_month_starts_on: u32,
|
||||||
number_of_days_in_month: usize,
|
number_of_days_in_month: u32,
|
||||||
selected_year: i32,
|
selected_year: i32,
|
||||||
selected_month: u32,
|
selected_month: u32,
|
||||||
}
|
}
|
||||||
@ -169,8 +169,7 @@ impl MonthHelper {
|
|||||||
|
|
||||||
match naive_date_result {
|
match naive_date_result {
|
||||||
Ok(naive_date) => {
|
Ok(naive_date) => {
|
||||||
self.day_number_month_starts_on =
|
self.day_number_month_starts_on = naive_date.weekday().num_days_from_sunday();
|
||||||
naive_date.weekday().num_days_from_sunday() as usize;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
@ -191,7 +190,7 @@ impl MonthHelper {
|
|||||||
|
|
||||||
match naive_date_result {
|
match naive_date_result {
|
||||||
Ok(naive_date) => {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
_ => Err(()),
|
_ => 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 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 = [
|
let days_of_the_week = [
|
||||||
"sunday",
|
"sunday",
|
||||||
|
Loading…
Reference in New Issue
Block a user