This is an automated email from the ASF dual-hosted git repository. kriskras99 pushed a commit to branch feat/enums in repository https://gitbox.apache.org/repos/asf/avro-rs.git
commit 0812b8f9892c55302b1f218f0e9f6ede23eebb85 Author: Kriskras99 <[email protected]> AuthorDate: Fri Mar 6 08:57:26 2026 +0100 docs --- avro_derive/src/attributes/mod.rs | 4 ++-- avro_derive/src/lib.rs | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/avro_derive/src/attributes/mod.rs b/avro_derive/src/attributes/mod.rs index 3a35f3c..13fadfe 100644 --- a/avro_derive/src/attributes/mod.rs +++ b/avro_derive/src/attributes/mod.rs @@ -396,7 +396,7 @@ impl FieldDefault { field_type: &Type, ) -> Result<TokenStream, Vec<syn::Error>> { match self { - FieldDefault::Disabled => Ok(quote! { None }), + FieldDefault::Disabled => Ok(quote! { ::std::option::Option::None }), FieldDefault::Trait => type_to_field_default_expr(field_type), FieldDefault::Value(default_value) => { let _: serde_json::Value = @@ -407,7 +407,7 @@ impl FieldDefault { )] })?; Ok(quote! { - Some(::serde_json::from_str(#default_value).expect(format!("Invalid JSON: {:?}", #default_value).as_str())) + ::std::option::Option::Some(::serde_json::from_str(#default_value).expect(format!("Invalid JSON: {:?}", #default_value).as_str())) }) } } diff --git a/avro_derive/src/lib.rs b/avro_derive/src/lib.rs index e0e8217..ccdffa3 100644 --- a/avro_derive/src/lib.rs +++ b/avro_derive/src/lib.rs @@ -302,6 +302,15 @@ fn get_field_schema_expr(field: &Field, with: With) -> Result<TokenStream, Vec<s } } +/// Call `get_record_fields_in_ctxt` for this field. +/// +/// # `TokenStream` +/// ## Context +/// The token stream expects the following variables to be defined: +/// - `named_schemas`: `&mut HashSet<Name>` +/// - `enclosing_namespace`: `Option<&str>` +/// ## Returns +/// A call to a `get_record_fields_in_ctxt(named_schemas, enclosing_namespace) -> Option<Vec<RecordField>>` fn get_field_get_record_fields_expr( field: &Field, with: With, @@ -338,6 +347,14 @@ fn get_field_get_record_fields_expr( } /// Takes in the Tokens of a type and returns the tokens of an expression with return type `Schema` +/// +/// # `TokenStream` +/// ## Context +/// The token stream expects the following variables to be defined: +/// - `named_schemas`: `&mut HashSet<Name>` +/// - `enclosing_namespace`: `Option<&str>` +/// ## Returns +/// A call to a `get_schema_in_ctxt(named_schemas, enclosing_namespace) -> Schema` fn type_to_schema_expr(ty: &Type) -> Result<TokenStream, Vec<syn::Error>> { match ty { Type::Array(_) | Type::Slice(_) | Type::Path(_) | Type::Reference(_) => Ok( @@ -477,7 +494,7 @@ fn named_to_record_fields( } /// Stolen from serde -fn to_compile_errors(errors: Vec<syn::Error>) -> proc_macro2::TokenStream { +fn to_compile_errors(errors: Vec<syn::Error>) -> TokenStream { let compile_errors = errors.iter().map(syn::Error::to_compile_error); quote!(#(#compile_errors)*) }
