This commit is contained in:
2026-03-24 13:40:33 +00:00
parent f994a566d8
commit ab2ebba286
6 changed files with 29 additions and 56 deletions
+3 -3
View File
@@ -85,7 +85,7 @@ impl fmt::Display for ModulePath {
/// Canonical exported/declared item name.
/// Invariants:
/// - must start with [A-Z]
/// - must start with [A-Za-z] (types/services typically use UpperCamel; functions may be lowerCamel)
/// - remaining chars: [A-Za-z0-9_]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
@@ -97,7 +97,7 @@ impl ItemName {
if s.is_empty() { return Err(CanonError::Empty("ItemName")); }
let mut chars = s.chars();
match chars.next() {
Some(c) if c.is_ascii_uppercase() => {}
Some(c) if c.is_ascii_alphabetic() => {}
_ => return Err(CanonError::InvalidStart("ItemName")),
}
if !s[1..].chars().all(|c| c.is_ascii_alphanumeric() || c == '_') {
@@ -310,7 +310,7 @@ mod tests {
fn item_name_rules() {
assert!(ItemName::new("Test").is_ok());
assert!(ItemName::new("Log2").is_ok());
assert!(ItemName::new("test").is_err());
assert!(ItemName::new("test").is_ok());
assert!(ItemName::new("_Test").is_err());
assert!(ItemName::new("Te-st").is_err());
}