-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make String
s in meta backwards compatible
#4438
Conversation
let string_ret = Box::new(str_value.clone()); | ||
let ret: Box<V> = unsafe { | ||
// We can transmute a String to V because we know that V==String | ||
std::mem::transmute(string_ret) | ||
}; | ||
Ok(Some(*ret)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to do this with a plain V
, the compiler complained about unknown size, this seemed like the easiest fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(@dpc used a similar unsafe trick elsewhere iirc, it's not new)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4ad6edc
to
20db0a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugly but works
let string_ret = Box::new(str_value.clone()); | ||
let ret: Box<V> = unsafe { | ||
// We can transmute a String to V because we know that V==String | ||
std::mem::transmute(string_ret) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting bounds here explicitly would make paranoid people feel a bit better about it.
For a long time we allowed plain strings in meta fields, i.e. without some ugly additional JSON quotation, but removed that bug/feature. Turns out that's a backwards incompatible change.
Related to #3648, #3699, #4432 and #4434.