From ddc8dc581767163f2770115ce78bb3f319f44c9a Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 19 Mar 2025 18:59:52 +0000 Subject: [PATCH] config derive: Improve and properly document InstanceConfigGlobal Signed-off-by: Ian Jackson --- server/server.rs | 2 +- src/config_derive.rs | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/server/server.rs b/server/server.rs index 32d06a7..568fe6f 100644 --- a/server/server.rs +++ b/server/server.rs @@ -179,7 +179,7 @@ async fn async_main(opts: Opts, daemon: Option) { return Ok(None); } - let global_config = config::InstanceConfigGlobal::from(&ics); + let global_config = config::InstanceConfigGlobal::from(ics); let gc = (&server_name, &global_config); if pc.keys().all(|k| gc.inspect_key(k).is_some()) { diff --git a/src/config_derive.rs b/src/config_derive.rs index fd35ef1..0f9322a 100644 --- a/src/config_derive.rs +++ b/src/config_derive.rs @@ -54,13 +54,9 @@ define_derive_deftly! { /// } /// } /// - /// pub struct InstanceConfigCommon { ... } - /// impl InstanceConfigCommon { - /// pub fn from(l: &[InstanceConfig]) { InstanceConfigCommon { - /// field: ::resolve(l.iter().map(|e| &e.field)), - /// ... - /// } } - /// } + /// pub struct InstanceConfigGlobal { ... } + /// impl InspectableConfigAuto for InstanceConfigGlobal { ... } + /// impl From<&'_ [InstanceConfig]> for InstanceConfigGlobal { .. } /// ``` InstanceConfig expect items: @@ -122,8 +118,8 @@ define_derive_deftly! { ) } - impl InstanceConfigGlobal { - pub fn from(l: &[InstanceConfig]) -> InstanceConfigGlobal { + impl From<&'_ [InstanceConfig]> for InstanceConfigGlobal { + fn from(l: &[InstanceConfig]) -> InstanceConfigGlobal { InstanceConfigGlobal { $( ${when fmeta(global)} -- 2.30.2