mirror of
https://github.com/supleed2/sv-filelist-parser.git
synced 2024-11-10 01:35:49 +00:00
Ran clippy. Removed returns, lifetime in params
This commit is contained in:
parent
b91f785509
commit
cc689e66a0
22
src/lib.rs
22
src/lib.rs
|
@ -10,30 +10,30 @@ enum LineType<'a> {
|
||||||
// Unknown,
|
// Unknown,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_line<'a>(line: &'a str) -> LineType<'a> {
|
fn parse_line(line: &str) -> LineType {
|
||||||
let line = line.trim();
|
let line = line.trim();
|
||||||
if line.starts_with("-f ") {
|
if line.starts_with("-f ") {
|
||||||
let filelist_name = line.trim_start_matches("-f ");
|
let filelist_name = line.trim_start_matches("-f ");
|
||||||
return LineType::Filelist(filelist_name);
|
LineType::Filelist(filelist_name)
|
||||||
} else if line.starts_with("+define+") {
|
} else if line.starts_with("+define+") {
|
||||||
// remove +define+ from start and "+" from end
|
// remove +define+ from start and "+" from end
|
||||||
let defines = line.trim_start_matches("+define+").trim_end_matches("+");
|
let defines = line.trim_start_matches("+define+").trim_end_matches('+');
|
||||||
let mut define_map = HashMap::new();
|
let mut define_map = HashMap::new();
|
||||||
for define in defines.split("+") {
|
for define in defines.split('+') {
|
||||||
let split: Vec<&str> = define.splitn(2, "=").collect();
|
let split: Vec<&str> = define.splitn(2, '=').collect();
|
||||||
define_map.insert(split[0], split[1]);
|
define_map.insert(split[0], split[1]);
|
||||||
}
|
}
|
||||||
return LineType::Define(define_map);
|
LineType::Define(define_map)
|
||||||
} else if line.starts_with("+incdir+") {
|
} else if line.starts_with("+incdir+") {
|
||||||
// remove +incdir+ from start and "+" from end
|
// remove +incdir+ from start and "+" from end
|
||||||
let incdirs = line.trim_start_matches("+incdir+").trim_end_matches("+");
|
let incdirs = line.trim_start_matches("+incdir+").trim_end_matches('+');
|
||||||
let incdir_vec: Vec<&str> = incdirs.split("+").collect();
|
let incdir_vec: Vec<&str> = incdirs.split('+').collect();
|
||||||
return LineType::IncDir(incdir_vec);
|
LineType::IncDir(incdir_vec)
|
||||||
} else if line.starts_with("//") {
|
} else if line.starts_with("//") {
|
||||||
return LineType::Comment;
|
LineType::Comment
|
||||||
} else {
|
} else {
|
||||||
// Mark everything else as a File
|
// Mark everything else as a File
|
||||||
return LineType::File(line);
|
LineType::File(line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue