mirror of
https://github.com/danog/strum.git
synced 2024-11-30 04:28:59 +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! { {..} },
|
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() {
|
if arms.len() < variants.len() {
|
||||||
|
@ -19,6 +19,14 @@ fn to_blue_string() {
|
|||||||
assert_eq!(String::from("blue"), format!("{}", Color::Blue { hue: 0 }));
|
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]
|
#[test]
|
||||||
fn to_yellow_string() {
|
fn to_yellow_string() {
|
||||||
assert_eq!(String::from("yellow"), format!("{}", Color::Yellow));
|
assert_eq!(String::from("yellow"), format!("{}", Color::Yellow));
|
||||||
|
Loading…
Reference in New Issue
Block a user