File tree Expand file tree Collapse file tree 4 files changed +13
-12
lines changed
Expand file tree Collapse file tree 4 files changed +13
-12
lines changed Original file line number Diff line number Diff line change 1- normalize_comments = true
2- reorder_imports = true
3- group_imports = " StdExternalCrate"
1+ reorder_imports = true
42newline_style = " Unix"
5- imports_granularity = " Module"
Original file line number Diff line number Diff line change 11# Client generator for golem projects
22
3- Rust client renerator for OpenAPI of [ Golem] ( https://golem.cloud ) projects.
3+ Rust client generator for OpenAPI of [ Golem] ( https://golem.cloud ) projects.
44
55This is not a general purpose client generator - it might be able to generate Rust clients for other OpenAPI specs produced by [ Poem OpenAPI] ( https://crates.io/crates/poem-openapi ) , but this is not the goal of this project.
Original file line number Diff line number Diff line change @@ -227,8 +227,7 @@ impl<C: PrintContext> Add<NewLine> for TreePrinter<C> {
227227
228228#[ cfg( test) ]
229229mod tests {
230-
231- use crate :: printer:: { PrintContext , Printer , TreePrinter } ;
230+ use crate :: printer:: { PrintContext , TreePrinter } ;
232231
233232 struct StringContext {
234233 ctx : String ,
@@ -252,7 +251,7 @@ mod tests {
252251
253252 let mut ctx = StringContext { ctx : String :: new ( ) } ;
254253
255- p. printer ( ) . print ( & mut ctx) ;
254+ p. print ( & mut ctx) ;
256255
257256 assert_eq ! ( ctx. ctx, "abc" )
258257 }
@@ -265,7 +264,7 @@ mod tests {
265264
266265 let mut ctx = StringContext { ctx : String :: new ( ) } ;
267266
268- p. printer ( ) . print ( & mut ctx) ;
267+ p. print ( & mut ctx) ;
269268
270269 assert_eq ! ( ctx. ctx, "abcdef" )
271270 }
Original file line number Diff line number Diff line change @@ -123,8 +123,13 @@ pub fn line<T: IntoRustTree>(code: T) -> TreePrinter<RustContext> {
123123}
124124
125125pub fn rust_name ( import : & str , name : & str ) -> TreePrinter < RustContext > {
126+ let import_name = if name. ends_with ( '!' ) {
127+ & name[ 0 ..name. len ( ) - 1 ]
128+ } else {
129+ name
130+ } ;
126131 TreePrinter :: leaf ( RustCode {
127- imports : HashSet :: from ( [ RustUse ( format ! ( "{import}::{name }" ) ) ] ) ,
132+ imports : HashSet :: from ( [ RustUse ( format ! ( "{import}::{import_name }" ) ) ] ) ,
128133 code : name. to_string ( ) ,
129134 } )
130135}
@@ -155,10 +160,10 @@ mod tests {
155160 let error = rust_name ( "trace" , "error!" ) ;
156161
157162 #[ rustfmt:: skip]
158- let p = unit ( )
163+ let p = unit ( )
159164 + line ( "pub fn m() {" )
160165 + indented (
161- line ( info + "(\" abc\" );" )
166+ line ( info + "(\" abc\" );" )
162167 + line ( error + "(\" def\" )" ) )
163168 + line ( "}" ) ;
164169
You can’t perform that action at this time.
0 commit comments