Fix clippy lints
This commit is contained in:
parent
44b019a7b4
commit
8ba9f22430
5 changed files with 7 additions and 18 deletions
|
|
@ -9,14 +9,8 @@ pub struct Config {
|
|||
pub note_extensions: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(StructOpt)]
|
||||
#[derive(StructOpt, Default)]
|
||||
pub struct ListOptions {
|
||||
#[structopt(short, long)]
|
||||
pub all: bool,
|
||||
}
|
||||
|
||||
impl Default for ListOptions {
|
||||
fn default() -> Self {
|
||||
ListOptions { all: false }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ impl Course {
|
|||
let mut coursestring = String::new();
|
||||
handle = File::open(&path).unwrap();
|
||||
handle.read_to_string(&mut coursestring).unwrap();
|
||||
let mut course: Course = toml::from_str(&coursestring).expect(&format!("{:?}", &path));
|
||||
let mut course: Course = toml::from_str(&coursestring)?;
|
||||
course.path = path.parent().unwrap().to_path_buf();
|
||||
if options.all || course.is_current() {
|
||||
courses.push(course);
|
||||
|
|
|
|||
10
src/main.rs
10
src/main.rs
|
|
@ -116,16 +116,12 @@ fn list_lectures(conf: &Config, options: ListOptions) -> Result<Vec<PathBuf>> {
|
|||
|
||||
let lectures = lectures?
|
||||
.into_iter()
|
||||
.filter_map(|path| {
|
||||
.filter(|path| {
|
||||
if let Some(ext) = path.extension() {
|
||||
let ext = ext.to_owned().to_string_lossy().into();
|
||||
if conf.note_extensions.contains(&ext) {
|
||||
Some(path)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
conf.note_extensions.contains(&ext)
|
||||
} else {
|
||||
None
|
||||
false
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ pub fn select_meeting(conf: &Config, options: &ListOptions) -> Result<()> {
|
|||
let meetings: Vec<_> = Course::list(conf, options)?
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|c: Course| {
|
||||
.flat_map(|c: Course| {
|
||||
if let Some(meetings) = c.meetings() {
|
||||
meetings.clone()
|
||||
} else {
|
||||
|
|
@ -30,7 +30,6 @@ pub fn select_meeting(conf: &Config, options: &ListOptions) -> Result<()> {
|
|||
.map(move |m| (c.clone(), m.clone()))
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.flatten()
|
||||
.collect();
|
||||
let meeting_names: Vec<_> = meetings
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
|
|||
use std::time::SystemTime;
|
||||
|
||||
pub fn to_snail_case(from: impl Into<String>) -> String {
|
||||
from.into().replace(" ", "_").to_lowercase()
|
||||
from.into().replace(' ', "_").to_lowercase()
|
||||
}
|
||||
|
||||
// pub fn to_title_case(from: &str) -> String {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue