File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
crates/cargo-util-schemas/src Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -1209,7 +1209,7 @@ str_newtype!(PackageName);
12091209impl < T : AsRef < str > > PackageName < T > {
12101210 /// Validated package name
12111211 pub fn new ( name : T ) -> Result < Self , NameValidationError > {
1212- restricted_names:: validate_package_name ( name. as_ref ( ) , "package name" ) ?;
1212+ restricted_names:: validate_package_name ( name. as_ref ( ) ) ?;
12131213 Ok ( Self ( name) )
12141214 }
12151215}
@@ -1231,7 +1231,7 @@ str_newtype!(RegistryName);
12311231impl < T : AsRef < str > > RegistryName < T > {
12321232 /// Validated registry name
12331233 pub fn new ( name : T ) -> Result < Self , NameValidationError > {
1234- restricted_names:: validate_package_name ( name. as_ref ( ) , "registry name" ) ?;
1234+ restricted_names:: validate_registry_name ( name. as_ref ( ) ) ?;
12351235 Ok ( Self ( name) )
12361236 }
12371237}
Original file line number Diff line number Diff line change @@ -33,13 +33,15 @@ enum ErrorKind {
3333 FeatureNameStartsWithDepColon ( String ) ,
3434}
3535
36- /// Check the base requirements for a package name.
37- ///
38- /// This can be used for other things than package names, to enforce some
39- /// level of sanity. Note that package names have other restrictions
40- /// elsewhere. `cargo new` has a few restrictions, such as checking for
41- /// reserved names. crates.io has even more restrictions.
42- pub ( crate ) fn validate_package_name ( name : & str , what : & ' static str ) -> Result < ( ) > {
36+ pub ( crate ) fn validate_package_name ( name : & str ) -> Result < ( ) > {
37+ validate_name ( name, "package name" )
38+ }
39+
40+ pub ( crate ) fn validate_registry_name ( name : & str ) -> Result < ( ) > {
41+ validate_name ( name, "registry name" )
42+ }
43+
44+ pub ( crate ) fn validate_name ( name : & str , what : & ' static str ) -> Result < ( ) > {
4345 if name. is_empty ( ) {
4446 return Err ( ErrorKind :: Empty ( what) . into ( ) ) ;
4547 }
You can’t perform that action at this time.
0 commit comments