Skip to main content

is_unknown_variant_tag

Function is_unknown_variant_tag 

Source
fn is_unknown_variant_tag<T: DeserializeOwned>(tag: &str) -> bool
Expand description

Decides whether tag names a variant unknown to T, without T having to enumerate its variants.

Two probe payloads ({"tag": null} and {"tag": true}) are re-deserialized for the same tag:

  • If T accepts either payload, the tag is recognized (a known variant).
  • If both are rejected, the tag is unknown iff the two errors are identical. An unknown variant yields a payload-independent “unknown variant” error for both probes, whereas a known variant rejects null and bool with different “invalid type” messages.