Skip to content

Commit 75d615a

Browse files
committed
Fix
1 parent 3c3f276 commit 75d615a

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

.rustfmt.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
normalize_comments = true
2-
reorder_imports = true
3-
group_imports = "StdExternalCrate"
1+
reorder_imports = true
42
newline_style = "Unix"
5-
imports_granularity = "Module"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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

55
This 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.

src/printer.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ impl<C: PrintContext> Add<NewLine> for TreePrinter<C> {
227227

228228
#[cfg(test)]
229229
mod 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
}

src/rust/printer.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,13 @@ pub fn line<T: IntoRustTree>(code: T) -> TreePrinter<RustContext> {
123123
}
124124

125125
pub 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

0 commit comments

Comments
 (0)