Skip to content

Commit

Permalink
Satisfied clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Linus-Mussmaecher committed May 28, 2024
1 parent 2bdcb41 commit 3dc7e18
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl App {
pub fn new(config: config::Config) -> Self {
// Index all files in path
let index = Rc::new(RefCell::new(data::NoteIndex::new(
&std::path::Path::new(&config.get_vault_path()),
std::path::Path::new(&config.get_vault_path()),
&config,
)));

Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl Config {
// if none was given, expand the path given from the config file
.or_else(|| {
config_file.vault_path.and_then(|conf_path_buf| {
expanduser::expanduser(conf_path_buf.to_string_lossy().to_string()).ok()
expanduser::expanduser(conf_path_buf.to_string_lossy()).ok()
})
});

Expand Down Expand Up @@ -163,7 +163,7 @@ impl Config {
target: &mut impl std::io::Write,
) -> Result<(), error::RucolaError> {
if let Some(prep) = &self.config_file.html_prepend {
target.write(prep.as_bytes())?;
target.write_all(prep.as_bytes())?;
}
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/data/notefile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub fn create_note_file(
)?;

// Add the file to the index if nothing threw and error and early returned.
index.borrow_mut().register(&path::Path::new(&path));
index.borrow_mut().register(path::Path::new(&path));

Ok(())
}
Expand Down Expand Up @@ -233,7 +233,7 @@ pub fn create_html(

let mut tar_file = std::fs::File::create(tar_path.clone())?;

write!(tar_file, "<title>{}</title>\n", note.name)?;
writeln!(tar_file, "<title>{}</title>", note.name)?;
config.prepend_to_html(&mut tar_file)?;

comrak::format_html(
Expand Down
15 changes: 7 additions & 8 deletions src/ui/screen/display_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,12 @@ impl super::Screen for DisplayScreen {
.tags
.iter()
.enumerate()
.map(|(index, s)| {
.flat_map(|(index, s)| {
[
Span::styled(if index == 0 { "" } else { ", " }, styles.text_style),
Span::styled(s.as_str(), styles.subtitle_style),
]
})
.flatten()
.collect_vec();

// Stats Area
Expand Down Expand Up @@ -175,21 +174,21 @@ impl super::Screen for DisplayScreen {
KeyCode::Left | KeyCode::Char('H' | 'h') => ui::Message::DisplayStackPop,
// Go up in the current list with k
KeyCode::Up | KeyCode::Char('K' | 'k') => {
self.selected
.get_mut(self.foc_table)
.map(|selected| *selected = selected.saturating_sub(1));
if let Some(selected) = self.selected.get_mut(self.foc_table) {
*selected = selected.saturating_sub(1);
}
ui::Message::None
}
// Go down in the current list with j
KeyCode::Down | KeyCode::Char('J' | 'j') => {
self.selected.get_mut(self.foc_table).map(|selected| {
if let Some(selected) = self.selected.get_mut(self.foc_table) {
*selected = selected.saturating_add(1).min(
self.links
.get(self.foc_table)
.map(|list| list.len().saturating_sub(1))
.unwrap_or_default(),
)
});
);
}
ui::Message::None
}
// Change list with Tab
Expand Down
2 changes: 1 addition & 1 deletion src/ui/screen/select_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl SelectScreen {
SortingMode::GlobalInLinks => env_stats.inlinks_global,
SortingMode::LocalInLinks => env_stats.inlinks_local,
SortingMode::Score => env_stats.match_score as usize,
SortingMode::Broken => env_stats.broken_links as usize,
SortingMode::Broken => env_stats.broken_links,
}
} else {
0
Expand Down

0 comments on commit 3dc7e18

Please # to comment.