@@ -1061,7 +1061,7 @@ impl fmt::Debug for Config {
1061
1061
}
1062
1062
1063
1063
/// A Rust module path for a Protobuf package.
1064
- #[ derive( Clone , PartialEq , Eq , Hash ) ]
1064
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
1065
1065
pub struct Module {
1066
1066
components : Vec < String > ,
1067
1067
}
@@ -1092,7 +1092,7 @@ impl Module {
1092
1092
}
1093
1093
}
1094
1094
1095
- /// An iterator over the parts of the path
1095
+ /// An iterator over the parts of the path.
1096
1096
pub fn parts ( & self ) -> impl Iterator < Item = & str > {
1097
1097
self . components . iter ( ) . map ( |s| s. as_str ( ) )
1098
1098
}
@@ -1117,6 +1117,11 @@ impl Module {
1117
1117
self . components . len ( )
1118
1118
}
1119
1119
1120
+ /// Whether the module's path contains any components.
1121
+ pub fn is_empty ( & self ) -> bool {
1122
+ self . components . is_empty ( )
1123
+ }
1124
+
1120
1125
fn to_partial_file_name ( & self , range : RangeToInclusive < usize > ) -> String {
1121
1126
self . components [ range] . join ( "." )
1122
1127
}
@@ -1126,6 +1131,20 @@ impl Module {
1126
1131
}
1127
1132
}
1128
1133
1134
+ impl fmt:: Display for Module {
1135
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1136
+ let mut parts = self . parts ( ) ;
1137
+ if let Some ( first) = parts. next ( ) {
1138
+ f. write_str ( first) ?;
1139
+ }
1140
+ for part in parts {
1141
+ f. write_str ( "::" ) ?;
1142
+ f. write_str ( part) ?;
1143
+ }
1144
+ Ok ( ( ) )
1145
+ }
1146
+ }
1147
+
1129
1148
/// Compile `.proto` files into Rust files during a Cargo build.
1130
1149
///
1131
1150
/// The generated `.rs` files are written to the Cargo `OUT_DIR` directory, suitable for use with
0 commit comments