Skip to content

Commit e6d5e5c

Browse files
committed
allow underscores in name annotations
1 parent 05ca544 commit e6d5e5c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

capnpc/src/codegen.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ fn snake_to_upper_case(s: &str) -> String {
111111
if c == '_' {
112112
result_chars.push('_');
113113
} else {
114-
assert!(c.is_alphanumeric(),
115-
format!("non-alphanumeric character '{}', i.e. {} in identifier '{}'",
116-
c, c as usize, s));
117114
result_chars.push(c.to_ascii_uppercase());
118115
}
119116
}
@@ -124,9 +121,6 @@ fn camel_to_snake_case(s: &str) -> String {
124121
let mut result_chars: Vec<char> = Vec::new();
125122
let mut first_char = true;
126123
for c in s.chars() {
127-
assert!(c.is_alphanumeric(),
128-
format!("non-alphanumeric character '{}', i.e. {} in identifier '{}'",
129-
c, c as usize, s));
130124
if c.is_uppercase() && !first_char {
131125
result_chars.push('_');
132126
}
@@ -175,6 +169,8 @@ fn test_camel_to_snake_case() {
175169
assert_eq!(camel_to_snake_case("helloWorld"), "hello_world".to_string());
176170
assert_eq!(camel_to_snake_case("HelloWorld"), "hello_world".to_string());
177171
assert_eq!(camel_to_snake_case("uint32Id"), "uint32_id".to_string());
172+
173+
assert_eq!(camel_to_snake_case("fooBar_"), "foo_bar_".to_string());
178174
}
179175

180176
#[derive(PartialEq, Clone)]

0 commit comments

Comments
 (0)