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);
1209
1209
impl < T : AsRef < str > > PackageName < T > {
1210
1210
/// Validated package name
1211
1211
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 ( ) ) ?;
1213
1213
Ok ( Self ( name) )
1214
1214
}
1215
1215
}
@@ -1231,7 +1231,7 @@ str_newtype!(RegistryName);
1231
1231
impl < T : AsRef < str > > RegistryName < T > {
1232
1232
/// Validated registry name
1233
1233
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 ( ) ) ?;
1235
1235
Ok ( Self ( name) )
1236
1236
}
1237
1237
}
Original file line number Diff line number Diff line change @@ -33,13 +33,15 @@ enum ErrorKind {
33
33
FeatureNameStartsWithDepColon ( String ) ,
34
34
}
35
35
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 < ( ) > {
43
45
if name. is_empty ( ) {
44
46
return Err ( ErrorKind :: Empty ( what) . into ( ) ) ;
45
47
}
You can’t perform that action at this time.
0 commit comments