From 6af779121c0124291b52102cf646ea4430c5226f Mon Sep 17 00:00:00 2001 From: bnewbold Date: Mon, 25 Apr 2016 17:36:12 -0400 Subject: rust: allow digits in identifiers (after 1st char) --- rust/spectrum.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rust') diff --git a/rust/spectrum.rs b/rust/spectrum.rs index c5ebad3..15c1f7b 100644 --- a/rust/spectrum.rs +++ b/rust/spectrum.rs @@ -63,8 +63,8 @@ fn is_valid_identifier(s: &str) -> bool { if s.starts_with("-") || s.ends_with("-") { return false; } - for c in s.chars() { - if !(c.is_alphabetic() || c == '-') { + for (i, c) in s.chars().enumerate() { + if !(c.is_alphabetic() || c == '-' || (c.is_numeric() && i > 0)) { return false; } } -- cgit v1.2.3