satisfy clippy

This commit is contained in:
Ernaldis 2023-09-15 13:42:35 -05:00
parent 6d31caa73f
commit e32ed45110
No known key found for this signature in database
GPG key ID: 5C2C4C2F84BFC021
2 changed files with 7 additions and 6 deletions

View file

@ -28,7 +28,8 @@ pub struct Line {
impl Line {
// creates a new line struct from plaintext
#[must_use] pub fn new(plaintext: &str, line_number: usize) -> Self {
#[must_use]
pub fn new(plaintext: &str, line_number: usize) -> Self {
Self {
plaintext: Some(plaintext.trim().to_string()),
line_number: Some(line_number),
@ -38,7 +39,8 @@ impl Line {
}
// creates a new line from an existing activity
#[must_use] pub fn for_activity(activity: activity::Activity) -> Self {
#[must_use]
pub fn for_activity(activity: activity::Activity) -> Self {
Self {
plaintext: None,
line_number: None,
@ -61,7 +63,7 @@ pub fn get_file_content(file_name: &str) -> Result<Vec<Line>> {
let lines = reader
.lines()
.filter_map(std::result::Result::ok)
.map_while(Result::ok)
.enumerate()
.map(|(line_number, line)| Line::new(&line, line_number.saturating_add(1)))
.collect();

View file

@ -32,8 +32,7 @@ impl<'a> fmt::Display for Report<'a> {
let mut longest_line = get_longest_line(&self.project_map).unwrap_or(0);
let longest_duration_string = get_longest_duration_string(self).unwrap_or(0);
let terminal_width = term_size::dimensions_stdout()
.map_or(conf::DEFAULT_WIDTH, |d| d.0);
let terminal_width = term_size::dimensions_stdout().map_or(conf::DEFAULT_WIDTH, |d| d.0);
if terminal_width < longest_line + longest_duration_string + 1 {
longest_line = terminal_width - longest_duration_string - 1;
@ -73,7 +72,7 @@ fn create_project_map<'a>(activities: &'a [&'a activity::Activity]) -> ProjectMa
.push(a);
}
for (_project, (activities, duration)) in &mut project_map {
for (activities, duration) in project_map.values_mut() {
*duration = sum_duration(activities);
}