We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3e5f0b4 commit bfaf988Copy full SHA for bfaf988
src/models/keyword.rs
@@ -50,14 +50,13 @@ impl Keyword {
50
}
51
52
pub fn valid_name(name: &str) -> bool {
53
- if name.is_empty() {
54
- return false;
55
- }
56
- // unwrap is okay because name is non-empty
57
- name.chars().next().unwrap().is_ascii_alphanumeric()
58
- && name
59
- .chars()
60
- .all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-')
+ let mut chars = name.chars();
+ let first = match chars.next() {
+ None => return false,
+ Some(c) => c,
+ };
+ first.is_ascii_alphanumeric()
+ && chars.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-')
61
62
63
pub fn update_crate(conn: &PgConnection, krate: &Crate, keywords: &[&str]) -> QueryResult<()> {
0 commit comments