Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ fn check_name(name: &str) -> CargoResult<()> {
name)
}

if let Some(ref c) = name.chars().nth(0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better style to use .next() here instead of .nth(0)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, char is Copy so we don't need the ref here

if c.is_digit(10) {
bail!("Package names starting with a digit cannot be used as a crate name\n\
use --name to override crate name")
}
}

for c in name.chars() {
if c.is_alphanumeric() { continue }
if c == '_' || c == '-' { continue }
Expand Down