You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2022/04/12 03:02:20 UTC

[GitHub] [avro] jklamer commented on pull request #1631: AVRO-3479: [rust] Avro Schema Derive Proc Macro [WIP]

jklamer commented on PR #1631:
URL: https://github.com/apache/avro/pull/1631#issuecomment-1095891894

   @martin-g darling is exactly what I was thinking there should be when I was making it! Refactored it a bit to break it up into NamedTypes and their schema options , and fields and their schema options! So we get docs on fields and types out of the box and super easily.  Check it out:
   ```
   #[derive(Debug, Serialize, Deserialize, AvroSchema, Clone, PartialEq)]
       #[avro(namespace = "com.testing.namespace", doc = "A Documented Record")]
       struct TestBasicWithAttributes {
           #[avro(doc = "Documented Field")]
           a: i32,
           b: String,
       }
   ```
   
   Also I was able to solve the `doc` issue where ToTokens on Option was flattening away None by manually preserving it in the output tokens:
   ```
   fn preserve_optional(op: Option<impl quote::ToTokens>) -> TokenStream {
       match op {
           Some(tt) => quote! {Some(#tt.to_owned())},
           None => quote! {None},
       }
   }
   ```
    


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org