Skip to content

Commit

Permalink
remove: ugly indentation and simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
MordechaiHadad committed Dec 28, 2023
1 parent 4d223d3 commit 636ec32
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/handlers/list_handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{anyhow, Result};
use regex::Regex;
use std::fs;
use std::{fs, path::PathBuf};
use yansi::Paint;

use crate::{
Expand All @@ -11,12 +11,10 @@ use crate::{
pub async fn start(config: Config) -> Result<()> {
let downloads_dir = directories::get_downloads_directory(&config).await?;

let mut paths = Vec::new();
for entry in fs::read_dir(downloads_dir)? {
if let Ok(v) = entry {
paths.push(v.path());
}
}
let paths: Vec<PathBuf> = fs::read_dir(downloads_dir)?
.filter_map(Result::ok)
.map(|entry| entry.path())
.collect();

if paths.is_empty() {
return Err(anyhow!("There are no versions installed"));
Expand Down

0 comments on commit 636ec32

Please sign in to comment.