title: How do I use serde to deserialize into a specific enum variant?
body: <p>I have an enum defined as:</p>
  
  <pre class="lang-rust prettyprint-override"><code>enum Foo {
      Bar { x: i32, y: i32 },
      ... // many more variants
  }
  </code></pre>
  
  <p>Given a JSON string <code>{"x": 5, "y": 7}</code> how would I deserialize explicitly to <code>Foo::Bar {x: 5, y: 7}</code>?</p>
  
  <p>Ideally I would be able to call into the deserializer for a particular variant, i.e. <code>Foo::Bar</code> in my example, rather than resort to something like <code>#[serde(untagged)]</code> which is a poor fit when you know in advance which variant to use.</p>
  
  <p>I could define <code>Bar</code> as a type in its own right but since it's only ever used in the context of <code>Foo</code>, it doesn't seem like the most elegant and/or succinct solution.</p>