diff --git a/examples/simple.rs b/examples/simple.rs index a3d8289..9f2181b 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -3,10 +3,10 @@ use confique::Config; #[derive(Debug, Config)] struct Conf { - #[config(child)] + #[config(nested)] http: Http, - #[config(child)] + #[config(nested)] cat: Cat, } diff --git a/macro/src/gen.rs b/macro/src/gen.rs index 6c5ce48..71ffae6 100644 --- a/macro/src/gen.rs +++ b/macro/src/gen.rs @@ -107,7 +107,7 @@ fn gen_partial_mod(input: &ir::Input) -> TokenStream { Some(confique::internal::deserialize_default(#default).expect(#msg)) } } - FieldKind::Child => { + FieldKind::Nested => { if unwrap_option(&f.ty).is_some() { quote! { Some(confique::Partial::default_values()) } } else { @@ -166,10 +166,10 @@ fn gen_meta(input: &ir::Input) -> TokenStream { let name = f.name.to_string(); let doc = &f.doc; let kind = match &f.kind { - FieldKind::Child => { + FieldKind::Nested => { let ty = &f.ty; quote! { - confique::meta::FieldKind::Child { meta: &<#ty as confique::Config>::META } + confique::meta::FieldKind::Nested { meta: &<#ty as confique::Config>::META } } } FieldKind::Leaf { default } => { diff --git a/macro/src/ir.rs b/macro/src/ir.rs index f9f0469..c5d2e1f 100644 --- a/macro/src/ir.rs +++ b/macro/src/ir.rs @@ -30,7 +30,7 @@ pub(crate) enum FieldKind { Leaf { default: Option, }, - Child, + Nested, } /// The kinds of expressions (just literals) we allow for default or example @@ -75,15 +75,15 @@ impl Field { let attrs = extract_internal_attrs(&mut field.attrs)?; // TODO: check no other attributes are here - let kind = if attrs.child { + let kind = if attrs.nested { if attrs.default.is_some() { return Err(Error::new( field.ident.span(), - "cannot specify `child` and `default` attributes at the same time", + "cannot specify `nested` and `default` attributes at the same time", )); } - FieldKind::Child + FieldKind::Nested } else { FieldKind::Leaf { default: attrs.default, @@ -186,9 +186,9 @@ fn extract_internal_attrs( duplicate_if!(out.default.is_some()); out.default = Some(expr); } - InternalAttr::Child => { - duplicate_if!(out.child); - out.child = true; + InternalAttr::Nested => { + duplicate_if!(out.nested); + out.nested = true; } } } @@ -198,19 +198,19 @@ fn extract_internal_attrs( #[derive(Default)] struct InternalAttrs { - child: bool, + nested: bool, default: Option, } enum InternalAttr { - Child, + Nested, Default(Expr), } impl InternalAttr { fn keyword(&self) -> &'static str { match self { - Self::Child => "child", + Self::Nested => "nested", Self::Default(_) => "default", } } @@ -220,9 +220,9 @@ impl Parse for InternalAttr { fn parse(input: ParseStream) -> Result { let ident: syn::Ident = input.parse()?; match &*ident.to_string() { - "child" => { + "nested" => { assert_empty(input)?; - Ok(Self::Child) + Ok(Self::Nested) } "default" => { let _: Token![=] = input.parse()?; diff --git a/src/meta.rs b/src/meta.rs index b8d1178..e544ca4 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -28,7 +28,7 @@ pub enum FieldKind { Leaf { default: Option, }, - Child { + Nested { meta: &'static Meta, }, }