mirror of
https://github.com/danog/strum.git
synced 2024-11-29 20:18:58 +01:00
Fix Display macro to handle fill/align
This commit is contained in:
parent
a20ee16d6b
commit
740e62cda3
@ -47,7 +47,7 @@ pub fn display_inner(ast: &syn::DeriveInput) -> TokenStream {
|
||||
Named(..) => quote! { {..} },
|
||||
};
|
||||
|
||||
arms.push(quote! { #name::#ident #params => f.write_str(#output) });
|
||||
arms.push(quote! { #name::#ident #params => f.pad(#output) });
|
||||
}
|
||||
|
||||
if arms.len() < variants.len() {
|
||||
|
@ -19,6 +19,14 @@ fn to_blue_string() {
|
||||
assert_eq!(String::from("blue"), format!("{}", Color::Blue { hue: 0 }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_formatters() {
|
||||
assert_eq!(String::from(" blue"), format!("{:>6}", Color::Blue { hue: 0 }));
|
||||
assert_eq!(String::from("blue "), format!("{:<6}", Color::Blue { hue: 0 }));
|
||||
assert_eq!(String::from(" blue "), format!("{:^6}", Color::Blue { hue: 0 }));
|
||||
assert_eq!(String::from("bl"), format!("{:.2}", Color::Blue { hue: 0 }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn to_yellow_string() {
|
||||
assert_eq!(String::from("yellow"), format!("{}", Color::Yellow));
|
||||
|
Loading…
Reference in New Issue
Block a user