Skip to content

Commit

Permalink
Use split_once to simplify the code.
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Pratt <jacob@jhpratt.dev>
  • Loading branch information
2 people authored and Turbo87 committed Dec 30, 2021
1 parent 8daf8e9 commit 2b4430c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/models/krate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,8 @@ impl Crate {

/// Validates a whole feature string, `features = ["THIS", "ALL/THIS"]`.
pub fn valid_feature(name: &str) -> bool {
match name.find('/') {
Some(pos) => {
let (dep, dep_feat) = name.split_at(pos);
let dep_feat = &dep_feat[1..];
match name.split_once('/') {
Some((dep, dep_feat)) => {
let dep = dep.strip_suffix('?').unwrap_or(dep);
Crate::valid_feature_prefix(dep) && Crate::valid_feature_name(dep_feat)
}
Expand Down

0 comments on commit 2b4430c

Please sign in to comment.