I've been staring at this test for awhile - and I'm so confused by these two logs(from the same site) ran in succession on the same test case:
is_multiline: true, item: PncApply(
@0-1 NumLiteral(
"1",
),
[
@2-3 Identifier {
ident: "i",
},
@4-5 SpaceAfter(
Identifier {
ident: "p",
},
[
LineComment(
"",
),
],
),
],
)
is_multiline: false, item: PncApply(
@0-1 NumLiteral(
"1",
),
Collection {
items: [
@7-8 SpaceBefore(
Identifier {
ident: "i",
},
[
Newline,
],
),
@14-15 SpaceBefore(
Identifier {
ident: "p",
},
[
Newline,
],
),
],
final_comments: [
LineComment(
"",
),
],
},
)
One shows that the enum variant's second arg is a slice and in the other that same enum variant's second arg is an ast::Collection.
Is there something I don't know about in Rust that could be going on here?
is it actually a slice, or do we have a custom Debug
implementation which is printing it out as [
... ]
in some situations but not all situations?
Feels like the latter, but can't tell without seeing the code
I have this line:
println!("Pattern::PncApply args {:#?}", args);
And it also does the same thing
Pattern::PncApply args [
@2-3 Identifier {
ident: "i",
},
@4-5 SpaceAfter(
Identifier {
ident: "p",
},
[
LineComment(
"",
),
],
),
]
Pattern::PncApply args Collection {
items: [
@7-8 SpaceBefore(
Identifier {
ident: "i",
},
[
Newline,
],
),
@14-15 SpaceBefore(
Identifier {
ident: "p",
},
[
Newline,
],
),
],
final_comments: [
LineComment(
"",
),
],
}
It seems....maybe the derived implementation of Debug prints as just the items array when final_comments in empty?
And that's what it is. TIL. And hopefully you did too!
Last updated: Jul 06 2025 at 12:14 UTC