Skip to content

Commit 9d18311

Browse files
committed
simplify some format args
1 parent 5a15026 commit 9d18311

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

capnpc/src/codegen_types.rs

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -209,39 +209,31 @@ impl<'a> RustTypeInfo for type_::Reader<'a> {
209209
type_::Struct(_) => {
210210
let inner = element_type.type_string(gen, Leaf::Owned)?;
211211
Ok(format!(
212-
"::capnp::struct_list::{}<{}{}>",
213-
module.bare_name(),
214-
lifetime_comma,
215-
inner
212+
"::capnp::struct_list::{}<{lifetime_comma}{inner}>",
213+
module.bare_name()
216214
))
217215
}
218216
type_::Enum(_) => {
219217
let inner = element_type.type_string(gen, Leaf::Owned)?;
220218
Ok(format!(
221-
"::capnp::enum_list::{}<{}{}>",
222-
module.bare_name(),
223-
lifetime_comma,
224-
inner
219+
"::capnp::enum_list::{}<{lifetime_comma}{inner}>",
220+
module.bare_name()
225221
))
226222
}
227223
type_::List(_) => {
228224
let inner = element_type.type_string(gen, Leaf::Owned)?;
229225
Ok(format!(
230-
"::capnp::list_list::{}<{}{}>",
231-
module.bare_name(),
232-
lifetime_comma,
233-
inner
226+
"::capnp::list_list::{}<{lifetime_comma}{inner}>",
227+
module.bare_name()
234228
))
235229
}
236230
type_::Text(()) => Ok(format!("::capnp::text_list::{module}")),
237231
type_::Data(()) => Ok(format!("::capnp::data_list::{module}")),
238232
type_::Interface(_) => {
239233
let inner = element_type.type_string(gen, Leaf::Client)?;
240234
Ok(format!(
241-
"::capnp::capability_list::{}<{}{}>",
242-
module.bare_name(),
243-
lifetime_comma,
244-
inner
235+
"::capnp::capability_list::{}<{lifetime_comma}{inner}>",
236+
module.bare_name()
245237
))
246238
}
247239
type_::AnyPointer(_) => {
@@ -250,10 +242,8 @@ impl<'a> RustTypeInfo for type_::Reader<'a> {
250242
_ => {
251243
let inner = element_type.type_string(gen, Leaf::Owned)?;
252244
Ok(format!(
253-
"::capnp::primitive_list::{}<{}{}>",
254-
module.bare_name(),
255-
lifetime_comma,
256-
inner
245+
"::capnp::primitive_list::{}<{lifetime_comma}{inner}>",
246+
module.bare_name()
257247
))
258248
}
259249
}
@@ -408,12 +398,15 @@ pub fn do_branding(
408398
"".to_string()
409399
};
410400

401+
let maybe_colons = if leaf == Leaf::ServerDispatch {
402+
"::"
403+
} else {
404+
""
405+
}; // HACK
411406
Ok(format!(
412-
"{mod}::{leaf}{maybe_colons}{arguments}",
413-
mod = the_mod,
414-
leaf = leaf.bare_name(),
415-
maybe_colons = if leaf == Leaf::ServerDispatch { "::" } else { "" }, // HACK
416-
arguments = arguments))
407+
"{the_mod}::{leaf}{maybe_colons}{arguments}",
408+
leaf = leaf.bare_name()
409+
))
417410
}
418411

419412
pub fn get_type_parameters(gen: &GeneratorContext, node_id: u64) -> Vec<String> {

0 commit comments

Comments
 (0)