mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 04:32:01 +03:00
25 lines
459 B
Rust
25 lines
459 B
Rust
use serde_json::from_str;
|
|
use swc_common::ast_serde;
|
|
|
|
#[ast_serde]
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
pub enum Ambiguous {
|
|
#[tag("A")]
|
|
A(A),
|
|
#[tag("B")]
|
|
B(B),
|
|
}
|
|
#[ast_serde("B")]
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
pub struct A {}
|
|
|
|
#[ast_serde("B")]
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
pub struct B {}
|
|
|
|
#[test]
|
|
fn deserialize() {
|
|
assert_eq!(A {}, from_str(r#"{"type": "A"}"#).unwrap());
|
|
assert_eq!(B {}, from_str(r#"{"type": "B"}"#).unwrap());
|
|
}
|