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
upgraded from 0.25.2 to 0.26. My previous code broke. here are the cases I reproduced. any suggestion?
case 1
use strum_macros::{AsRefStr,EnumString};#[derive(EnumString, strum_macros::Display,AsRefStr,Debug)]enumA{#[strum(serialize = "{}")]// <--- this lieBra,#[strum(serialize = "nor")]Nor,}fnmain(){println!("{}", A::Bra);// parselet a = "{}".parse::<A>();println!("{:?}", a);}
error: 1 positional argument in format string, but no arguments were given
--> src/main.rs:5:26
|
5 | #[strum(serialize = "{}")]
| ^^
error: could not compile `strum-demo` (bin "strum-demo") due to 1 previous error
case 2
use strum_macros::{AsRefStr,EnumString};#[derive(EnumString, strum_macros::Display,AsRefStr,Debug)]enumA{#[strum(serialize = "{{}}")]// <--- this lineBra,#[strum(serialize = "nor")]Nor,}fnmain(){println!("{}", A::Bra);// parselet a = "{}".parse::<A>();println!("{:?}", a);}
{}
Err(VariantNotFound)
case 3
use strum_macros::{AsRefStr,EnumString};#[derive(EnumString, strum_macros::Display,AsRefStr,Debug)]enumA{#[strum(serialize = "{{}}")]// <--- this lineBra,#[strum(serialize = "nor")]Nor,}fnmain(){println!("{}", A::Bra);// parselet a = "{{}}".parse::<A>();println!("{:?}", a);}
{}
Ok(Bra)
The text was updated successfully, but these errors were encountered:
Peternator7
changed the title
strange behavior using {} in serialize macro
Round tripping "{{}}" doesn't work with Display + EnumString
Jun 5, 2024
Peternator7
changed the title
Round tripping "{{}}" doesn't work with Display + EnumString
Round tripping "{{}}" doesn't work with Display + EnumString in 0.26
Jun 5, 2024
Hey @tiye, sorry for the break here. There was a breaking change upgrading to 0.26 around format strings, but it should work correctly with escaped curly-braces so that's a bug. I'll work on fixing this, but in the meantime, the best solution is going to be staying on 0.25
upgraded from
0.25.2
to0.26
. My previous code broke. here are the cases I reproduced. any suggestion?case 1
case 2
case 3
The text was updated successfully, but these errors were encountered: