Skip to content

Commit 2b4430c

Browse files
ehussjhpratt
authored andcommitted
Use split_once to simplify the code.
Co-authored-by: Jacob Pratt <[email protected]>
1 parent 8daf8e9 commit 2b4430c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/models/krate.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,8 @@ impl Crate {
297297

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

0 commit comments

Comments
 (0)