-
-
Notifications
You must be signed in to change notification settings - Fork 777
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
Untagged enum does not play nice with u128 #1682
Comments
Use
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
#[derive(Debug, PartialEq)]
pub struct S64 {
pub f: u64,
}
#[derive(Deserialize, Serialize)]
#[serde(untagged)]
#[derive(Debug, PartialEq)]
pub enum E64 {
S(S64),
}
#[derive(Deserialize, Serialize)]
#[derive(Debug, PartialEq)]
pub struct S128 {
pub f: u128,
}
#[derive(Deserialize, Serialize)]
#[serde(untagged)]
#[derive(Debug, PartialEq)]
pub enum E128 {
S(S128),
}
#[cfg(test)]
mod tests {
use serde_test::{assert_de_tokens, Token};
use super::*;
#[test]
fn token_test64() {
let expected_incoming = E64::S(S64 { f: 1 });
assert_de_tokens(&expected_incoming, &[
Token::Struct { name: "S64", len: 1},
Token::Str("f"),
Token::U64(1),
Token::StructEnd,
]);
}
#[test]
fn token_test128() {
let expected_incoming = E128::S(S128 { f: 1 });
assert_de_tokens(&expected_incoming, &[
Token::Struct { name: "S128", len: 1},
Token::Str("f"),
Token::U64(1),
Token::StructEnd,
]);
}
} No playground because of |
Confirmed #1679 and serde-rs/json#586 fixed the issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would expect both tests pass, but instead, only
test64
passed, whiletest128
failed withMaybe related to serde-rs/json#559
playground
The text was updated successfully, but these errors were encountered: