Skip to content

Commit

Permalink
Fix all clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Nov 4, 2021
1 parent a986475 commit 8c292c5
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 43 deletions.
17 changes: 10 additions & 7 deletions src/data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::cli::Opt;
use crate::theme::theme::Theme;
use crate::theme::Theme;
use clap::arg_enum;
use libmacchina::traits::ShellFormat;
use libmacchina::traits::{ReadoutError, ShellKind};
Expand Down Expand Up @@ -66,8 +66,11 @@ fn create_bar<'a>(theme: &Theme, blocks: usize) -> Spans<'a> {
if theme.bar.are_delimiters_hidden() {
let mut span_vector = vec![Span::raw(""), Span::raw("")];

let glyph = theme.bar.get_glyph().clone();
let glyphs = colored_glyphs(&glyph, blocks);
// This clone is useless since we can't really clone a &str
// this just clones the reference to the str
// let glyph = theme.bar.get_glyph().clone();
let glyph = theme.bar.get_glyph();
let glyphs = colored_glyphs(glyph, blocks);

if blocks == 10 {
span_vector[0].content = Cow::from(glyphs);
Expand All @@ -76,7 +79,7 @@ fn create_bar<'a>(theme: &Theme, blocks: usize) -> Spans<'a> {
}
span_vector[0].style = Style::default().fg(theme.get_key_color());

span_vector[1].content = Cow::from(colored_glyphs(&glyph, 10 - blocks));
span_vector[1].content = Cow::from(colored_glyphs(glyph, 10 - blocks));
if theme.get_key_color() == Color::White {
span_vector[1].content = Cow::from(span_vector[1].content.replace(&glyph, " "));
}
Expand All @@ -90,8 +93,8 @@ fn create_bar<'a>(theme: &Theme, blocks: usize) -> Spans<'a> {
Span::raw(format!(" {}", theme.bar.get_symbol_close())),
];

let glyph = theme.bar.get_glyph().clone();
let glyphs = colored_glyphs(&glyph, blocks);
let glyph = theme.bar.get_glyph();
let glyphs = colored_glyphs(glyph, blocks);

if blocks == 10 {
span_vector[1].content = Cow::from(glyphs);
Expand All @@ -100,7 +103,7 @@ fn create_bar<'a>(theme: &Theme, blocks: usize) -> Spans<'a> {
}
span_vector[1].style = Style::default().fg(theme.get_key_color());

span_vector[2].content = Cow::from(colored_glyphs(&glyph, 10 - blocks));
span_vector[2].content = Cow::from(colored_glyphs(glyph, 10 - blocks));
if theme.get_key_color() == Color::White {
span_vector[2].content = Cow::from(span_vector[2].content.replace(&glyph, " "));
}
Expand Down
64 changes: 32 additions & 32 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub mod widgets;

use crate::data::ReadoutKey;
use crate::theme::color::MacchinaColor;
use crate::theme::theme::Theme;
use crate::theme::Theme;
use crate::widgets::readout::ReadoutList;
use atty::Stream;
use data::Readout;
Expand Down Expand Up @@ -113,7 +113,7 @@ fn create_theme(opt: &Opt) -> Theme {
for dir in array::IntoIter::new(dirs) {
if let Ok(custom_theme) = Theme::get_theme(opt_theme, dir) {
found = true;
theme = Theme::from(custom_theme);
theme = custom_theme;
}
}

Expand Down Expand Up @@ -172,38 +172,38 @@ fn select_ascii(small: bool) -> Option<Text<'static>> {

fn list_themes() {
let dirs = [dirs::config_dir(), libmacchina::extra::localbase_dir()];
for i in array::IntoIter::new(dirs) {
if let Some(dir) = i {
let entries = libmacchina::extra::list_dir_entries(&dir.join("macchina/themes"));
if !entries.is_empty() {
let custom_themes = entries.iter().filter(|&x| {
if let Some(ext) = libmacchina::extra::path_extension(&x) {
ext == "toml"
} else {
false
}
});

if custom_themes.clone().count() == 0 {
println!(
"\nNo custom themes were found in {}",
dir.join("macchina/themes")
.to_string_lossy()
.bright_yellow()
)
// for i in array::IntoIter::new(dirs) {
// if let Some(dir) = i {
for dir in array::IntoIter::new(dirs).flatten() {
let entries = libmacchina::extra::list_dir_entries(&dir.join("macchina/themes"));
if !entries.is_empty() {
let custom_themes = entries.iter().filter(|&x| {
if let Some(ext) = libmacchina::extra::path_extension(x) {
ext == "toml"
} else {
false
}

custom_themes.for_each(|x| {
if let Some(theme) = x.file_name() {
let name = theme.to_string_lossy().replace(".toml", "");
println!(
"- {} ({}/macchina/themes)",
name.bright_green(),
&dir.to_string_lossy()
);
}
});
});

if custom_themes.clone().count() == 0 {
println!(
"\nNo custom themes were found in {}",
dir.join("macchina/themes")
.to_string_lossy()
.bright_yellow()
)
}

custom_themes.for_each(|x| {
if let Some(theme) = x.file_name() {
let name = theme.to_string_lossy().replace(".toml", "");
println!(
"- {} ({}/macchina/themes)",
name.bright_green(),
&dir.to_string_lossy()
);
}
});
}
}
}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/theme/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl Bar {
}

pub fn are_delimiters_hidden(&self) -> bool {
return self.symbol_open == '\0' && self.symbol_close == '\0';
self.symbol_open == '\0' && self.symbol_close == '\0'
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/theme/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod base;
pub mod color;
pub mod components;
pub mod theme;
pub use base::*;
4 changes: 2 additions & 2 deletions src/widgets/readout.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::data::{Readout, ReadoutKey};
use crate::theme::components::Palette;
use crate::theme::theme::Theme;
use crate::theme::Theme;
use std::collections::HashMap;
use tui::buffer::Buffer;
use tui::layout::{Margin, Rect};
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<'a> Widget for ReadoutList<'a> {
let keys = self.keys_to_text(&self.theme.get_key_color());
let max_key_width = Self::get_max_key_width(&keys);
let themed_separator = Self::get_themed_separator(
&self.theme.get_separator(),
self.theme.get_separator(),
&self.theme.get_separator_color(),
);

Expand Down

0 comments on commit 8c292c5

Please sign in to comment.