File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,10 @@ pub enum Error {
2727 /// New version must be greater than the most recent version
2828 VersionMustBeGreaterThanCurrent = 11 ,
2929 /// Invalid name.
30- /// Must be 64 characters or less; ascii alphanumeric or '_'; start with a letter; and not be a Rust keyword
30+ /// Must be 64 characters or less;
31+ /// ascii alphanumeric, '-', or '_';
32+ /// start with a ascii alphabetic character;
33+ /// and not be a Rust keyword
3134 InvalidName = 12 ,
3235 /// Invalid Version. Must be valid cargo version
3336 InvalidVersion = 13 ,
Original file line number Diff line number Diff line change @@ -12,10 +12,11 @@ pub(crate) fn is_valid(s: &String) -> bool {
1212 let Ok ( s) = core:: str:: from_utf8 ( first) else {
1313 return false ;
1414 } ;
15- if is_keyword ( s) || s. starts_with ( |c : char | c == '_' || c . is_numeric ( ) ) {
15+ if is_keyword ( s) || ! s. starts_with ( |c : char | c. is_ascii_alphabetic ( ) ) {
1616 return false ;
1717 }
18- s. chars ( ) . all ( |c| c. is_ascii_alphanumeric ( ) || c == '_' )
18+ s. chars ( )
19+ . all ( |c| c. is_ascii_alphanumeric ( ) || c == '_' || c == '-' )
1920}
2021
2122pub ( crate ) fn validate ( s : & String ) -> Result < ( ) , Error > {
Original file line number Diff line number Diff line change @@ -125,8 +125,10 @@ fn validate_names() {
125125 "abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgha" ,
126126 false ,
127127 ) ;
128- test_string ( "a-a_b" , false ) ;
128+ test_string ( "a-a_b" , true ) ;
129+ test_string ( "a-a]]]_b" , false ) ;
129130 test_string ( "_ab" , false ) ;
131+ test_string ( "-ab" , false ) ;
130132 test_string ( "1ab" , false ) ;
131133}
132134
You can’t perform that action at this time.
0 commit comments