-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
In std::fmt
:
x
prints integers in hexadecimal format#x
prefixes hexadecimal numbers with a 0x#?
pretty-prints the Debug formatting (e.g. one vector element per line)
The problem is that those are not orthogonal. #x?
will both add 0x and pretty-print. There does not seem to be a way to get one behavior without the other.
let v = [11];
/*
[11]
*/
println!("{:?}", v);
/*
[
11,
]
*/
println!("{:#?}", v);
/*
[b]
*/
println!("{:x?}", v);
/*
[
0xb,
]
*/
println!("{:#x?}", v);
/*
[
b,
]
*/
// ??
/*
[0xb]
*/
// ??
Could the #
modifier apply only to the closest type, so that #x?
, x#?
and #x#?
could be used to denote each case? (this would cause an output change for #x?
). Alternatively, another letter to denote "hexadecimal with 0x prefix"?
Dirbaio, ikey4u, plwalsh, VisualEhrmanntraut, crazyboycjr and 15 more
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.