summaryrefslogtreecommitdiff
path: root/src/codegen/impl_debug.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen/impl_debug.rs')
-rw-r--r--src/codegen/impl_debug.rs50
1 files changed, 33 insertions, 17 deletions
diff --git a/src/codegen/impl_debug.rs b/src/codegen/impl_debug.rs
index a604fc92..077d5737 100644
--- a/src/codegen/impl_debug.rs
+++ b/src/codegen/impl_debug.rs
@@ -186,28 +186,44 @@ impl<'a> ImplDebug<'a> for Item {
// The simple case
debug_print(name, quote! { #name_ident })
} else {
- // Let's implement our own print function
+ if ctx.options().use_core {
+ // There is no String in core; reducing field visibility to avoid breaking
+ // no_std setups.
+ Some((
+ format!("{}: [...]", name), vec![]
+ ))
+ } else {
+ // Let's implement our own print function
+ Some((
+ format!("{}: [{{}}]", name),
+ vec![quote! {
+ self.#name_ident
+ .iter()
+ .enumerate()
+ .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v))
+ .collect::<String>()
+ }],
+ ))
+ }
+ }
+ }
+ TypeKind::Vector(_, len) => {
+ if ctx.options().use_core {
+ // There is no format! in core; reducing field visibility to avoid breaking
+ // no_std setups.
Some((
- format!("{}: [{{}}]", name),
+ format!("{}(...)", name), vec![]
+ ))
+ } else {
+ let self_ids = 0..len;
+ Some((
+ format!("{}({{}})", name),
vec![quote! {
- self.#name_ident
- .iter()
- .enumerate()
- .map(|(i, v)| format!("{}{:?}", if i > 0 { ", " } else { "" }, v))
- .collect::<String>()
- }],
+ #(format!("{:?}", self.#self_ids)),*
+ }]
))
}
}
- TypeKind::Vector(_, len) => {
- let self_ids = 0..len;
- Some((
- format!("{}({{}})", name),
- vec![quote! {
- #(format!("{:?}", self.#self_ids)),*
- }]
- ))
- }
TypeKind::ResolvedTypeRef(t) |
TypeKind::TemplateAlias(t, _) |