Run cargo clippy

This commit is contained in:
Dheepak Krishnamurthy 2020-10-22 22:02:42 -06:00
parent ef37326da3
commit b76a20186b
2 changed files with 8 additions and 14 deletions

View file

@ -408,12 +408,8 @@ impl TTApp {
.expect(format!("Unable to run `task _get rc.context.{}`", self.context_name).as_str()) .expect(format!("Unable to run `task _get rc.context.{}`", self.context_name).as_str())
.stdout, .stdout,
) )
.expect( .unwrap_or_else(
format!( |_| panic!("Unable to decode utf8 from stdout of `task _get rc.context.{}`", self.context_name)
"Unable to decode utf8 from stdout of `task _get rc.context.{}`",
self.context_name
)
.as_str(),
); );
self.context_filter = self.context_filter.strip_suffix('\n').unwrap_or("").to_string(); self.context_filter = self.context_filter.strip_suffix('\n').unwrap_or("").to_string();
} }
@ -461,7 +457,7 @@ impl TTApp {
tasks_with_styles tasks_with_styles
.extend(tasks_with_due_dates.map(|t| (t.due().unwrap().clone().date(), self.style_for_task(t)))) .extend(tasks_with_due_dates.map(|t| (t.due().unwrap().clone().date(), self.style_for_task(t))))
} }
return tasks_with_styles; tasks_with_styles
} }
pub fn draw_task(&mut self, f: &mut Frame<impl Backend>) { pub fn draw_task(&mut self, f: &mut Frame<impl Backend>) {
@ -1291,13 +1287,12 @@ impl TTApp {
add_tag(&mut task, "ANNOTATED".to_string()); add_tag(&mut task, "ANNOTATED".to_string());
} }
if task.tags().is_some() { if task.tags().is_some() {
let tags = task if !task
.tags() .tags()
.unwrap() .unwrap()
.iter() .iter()
.filter(|s| !self.task_report_table.virtual_tags.contains(s)) .filter(|s| !self.task_report_table.virtual_tags.contains(s))
.collect::<Vec<_>>(); .next().is_none() {
if !tags.is_empty() {
add_tag(&mut task, "TAGGED".to_string()); add_tag(&mut task, "TAGGED".to_string());
} }
} }

View file

@ -155,7 +155,7 @@ impl<'a> Widget for Calendar<'a> {
); );
let mut startm = 0 as usize; let mut startm = 0 as usize;
if self.months_per_row > area.width as usize / 8 / 3 || self.months_per_row <= 0 { if self.months_per_row > area.width as usize / 8 / 3 || self.months_per_row == 0 {
self.months_per_row = area.width as usize / 8 / 3; self.months_per_row = area.width as usize / 8 / 3;
} }
let mut y = area.y; let mut y = area.y;
@ -177,11 +177,10 @@ impl<'a> Widget for Calendar<'a> {
loop { loop {
let endm = std::cmp::min(startm + self.months_per_row, 12); let endm = std::cmp::min(startm + self.months_per_row, 12);
let mut x = area.x + startx; let mut x = area.x + startx;
for c in startm..endm { for (c, d) in days.iter_mut().enumerate().skip(startm).take(endm) {
if c > startm { if c > startm {
x += 1; x += 1;
} }
let d = &mut days[c];
let m = d.0.month() as usize; let m = d.0.month() as usize;
let s = format!("{:^20}", month_names[m - 1]); let s = format!("{:^20}", month_names[m - 1]);
let style = Style::default().bg(Color::Rgb(220, 220, 220)); let style = Style::default().bg(Color::Rgb(220, 220, 220));
@ -194,7 +193,7 @@ impl<'a> Widget for Calendar<'a> {
} }
y += 1; y += 1;
let mut x = area.x + startx; let mut x = area.x + startx;
for d in days.iter_mut().skip(startm).take(endm) { for (_, d) in days.iter_mut().enumerate().skip(startm).take(endm) {
let m = d.0.month() as usize; let m = d.0.month() as usize;
let style = Style::default().bg(Color::Rgb(220, 220, 220)); let style = Style::default().bg(Color::Rgb(220, 220, 220));
if m == today.month() as usize && self.year + year as i32 == today.year() { if m == today.month() as usize && self.year + year as i32 == today.year() {