@@ -12,6 +12,7 @@ pub enum ModuleType {
1212 Concept ,
1313 Procedure ,
1414 Reference ,
15+ Snippet ,
1516}
1617
1718// Implement human-readable string display for the module type
@@ -22,6 +23,7 @@ impl fmt::Display for ModuleType {
2223 Self :: Concept => "concept" ,
2324 Self :: Procedure => "procedure" ,
2425 Self :: Reference => "reference" ,
26+ Self :: Snippet => "snippet" ,
2527 } ;
2628 write ! ( f, "{}" , name)
2729 }
@@ -128,7 +130,7 @@ impl Input {
128130 ] ;
129131
130132 // Perform all the defined replacements on the title
131- for ( old, new) in substitutions. iter ( ) {
133+ for ( old, new) in substitutions. into_iter ( ) {
132134 title_with_replacements = title_with_replacements. replace ( old, new) ;
133135 }
134136
@@ -140,7 +142,7 @@ impl Input {
140142
141143 let prefix = self . prefix ( ) ;
142144
143- prefix + & title_with_replacements
145+ format ! ( "{}{}" , prefix, title_with_replacements)
144146 }
145147
146148 /// Prepare the file name for the generated file.
@@ -152,20 +154,20 @@ impl Input {
152154 self . id ( ) + suffix
153155 }
154156
155- fn prefix ( & self ) -> String {
157+ fn prefix ( & self ) -> & ' static str {
156158 if self . options . prefixes {
157159 // If prefixes are enabled, pick the right file prefix
158160 match self . mod_type {
159161 ModuleType :: Assembly => "assembly_" ,
160162 ModuleType :: Concept => "con_" ,
161163 ModuleType :: Procedure => "proc_" ,
162164 ModuleType :: Reference => "ref_" ,
165+ ModuleType :: Snippet => "snip_" ,
163166 }
164167 } else {
165168 // If prefixes are disabled, use an empty string for the prefix
166169 ""
167170 }
168- . to_string ( )
169171 }
170172
171173 /// Prepare an include statement that can be used to include the generated file from elsewhere.
@@ -193,9 +195,10 @@ impl Input {
193195 /// to determine it automatically.
194196 fn infer_include_dir ( & self ) -> Option < PathBuf > {
195197 // The first directory in the include path is either `assemblies/` or `modules/`,
196- // based on the module type.
198+ // based on the module type, or `snippets/` for snippet files .
197199 let include_root = match & self . mod_type {
198200 ModuleType :: Assembly => "assemblies" ,
201+ ModuleType :: Snippet => "snippets" ,
199202 _ => "modules" ,
200203 } ;
201204
0 commit comments