mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-20 11:47:46 +00:00
Use split_once in parse_repository_category
This commit is contained in:
parent
5c291a4844
commit
75aee9e9d8
1 changed files with 4 additions and 8 deletions
|
@ -201,21 +201,17 @@ impl GameData {
|
|||
|
||||
/// Parses a path structure and spits out the corresponding category and repository.
|
||||
fn parse_repository_category(&self, path: &str) -> Option<(&Repository, Category)> {
|
||||
let tokens: Vec<&str> = path.split('/').collect(); // TODO: use split_once here
|
||||
let tokens = path.split_once('/')?;
|
||||
|
||||
if tokens.len() < 2 {
|
||||
return None;
|
||||
}
|
||||
|
||||
let repository_token = tokens[1];
|
||||
let repository_token = tokens.1;
|
||||
|
||||
for repository in &self.repositories {
|
||||
if repository.name == repository_token {
|
||||
return Some((repository, string_to_category(tokens[0])?));
|
||||
return Some((repository, string_to_category(tokens.0)?));
|
||||
}
|
||||
}
|
||||
|
||||
Some((&self.repositories[0], string_to_category(tokens[0])?))
|
||||
Some((&self.repositories[0], string_to_category(tokens.0)?))
|
||||
}
|
||||
|
||||
fn get_index_filenames(&self, path: &str) -> Option<(Vec<(String, u8)>, Vec<(String, u8)>)> {
|
||||
|
|
Loading…
Add table
Reference in a new issue