You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use the debug print and a formatter such as {: <3?} with a enum to print the case name, the code does not work as expected.
#[derive(Debug)]enumMyEnum{AB,}fnmain(){let value = MyEnum::AB;println!("[{: <3?}]", value);// The result is `[AB]`// while I expected that the result is `[AB ]`.}
It's only work if the enum has a value:
#[derive(Debug)]enumMyEnum{AB(i32),}fnmain(){let value = MyEnum::AB(42);println!("[{:<3?}]", value);// The result is `[42 ]`}
The text was updated successfully, but these errors were encountered:
macabeus
changed the title
Formatted print not work as expected with debug + enum
Formatted print doesn't work as expected with debug + enum
Nov 7, 2018
If you use the debug print and a formatter such as
{: <3?}
with aenum
to print the case name, the code does not work as expected.It's only work if the enum has a value:
Maybe we should fix this behaviour?
Also, I've open a question at Stackoverflow about this behaviour.
The text was updated successfully, but these errors were encountered: