-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Error when deserializing into &str slice in release mode #67
Comments
Hi, good catch! I added a test: #[test]
fn foo_str() {
#[derive(Deserialize)]
struct FooStr<'de> {
foo: &'de str,
}
let mut json = br#"{"foo":"bar"}"#.to_vec();
let res = FooStr::from_slice(&mut json);
assert!(res.is_ok());
assert_eq!(res.unwrap().foo, "bar");
} Clearly a bug, not a panic however, it returns a Err the panic comes from the |
oh yeah whoops I wasn't paying attention when I wrote the MRE, just threw unwrap for convenience haha |
This is a really tricky one, I can reproduce it but I can't make sense of it so far |
Not sure if this helps, but I found out that the following works in release mode #[derive(Deserialize)]
struct FooOptionStr<'de> {
foo: Option<&'de str>,
} |
Okay, this took a lot of digging, but I found it. The use of The rewrite of the deserializer avoids I'll release this as 0.12.0 along with an entry in the |
Hey! I created a MRE for a bug I encountered below. This code compiles and works in debug mode, but in release the
FooStr
struct will not successfully deserialize.The text was updated successfully, but these errors were encountered: