title: How can I get the T from an Option<T> when using syn?
body: <p>I'm using <code>syn</code> to parse Rust code. When I read a named field's type using <code>field.ty</code>, I get a <code>syn::Type</code>. When I print it using <code>quote!{#ty}.to_string()</code> I get <code>"Option&lt;String&gt;"</code>. </p>
  
  <p>How can I get just <code>"String"</code>? I want to use <code>#ty</code> in <code>quote!</code> to print <code>"String"</code> instead of <code>"Option&lt;String&gt;"</code>.</p>
  
  <p>I want to generate code like:</p>
  
  <pre><code>impl Foo {
      pub set_bar(&amp;mut self, v: String) {
          self.bar = Some(v);
      }
  }
  </code></pre>
  
  <p>starting from</p>
  
  <pre><code>struct Foo {
      bar: Option&lt;String&gt;
  }
  </code></pre>
  
  <p>My attempt:</p>
  
  <pre><code>let ast: DeriveInput = parse_macro_input!(input as DeriveInput);
  
  let data: Data = ast.data;
  
  match data {
      Data::Struct(ref data) =&gt; match data.fields {
          Fields::Named(ref fields) =&gt; {
  
              fields.named.iter().for_each(|field| {
                  let name = &amp;field.ident.clone().unwrap();
  
                  let ty = &amp;field.ty;
                  quote!{
                      impl Foo {
                          pub set_bar(&amp;mut self, v: #ty) {
                              self.bar = Some(v);
                          }
                      }
                  };      
              });
          }
          _ =&gt; {}
      },
      _ =&gt; panic!("You can derive it only from struct"),
  }
  </code></pre>