From 0403753f977f659dc9b67ebef57099c3d80851bc Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Mon, 11 Mar 2024 01:01:15 +0900 Subject: [PATCH] Minor refactor --- crates/voicevox_core/src/infer.rs | 15 +++++++++++---- crates/voicevox_core/src/infer/domains.rs | 13 ++++++++++--- crates/voicevox_core/src/infer/status.rs | 2 +- crates/voicevox_core_macros/src/lib.rs | 1 + 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/crates/voicevox_core/src/infer.rs b/crates/voicevox_core/src/infer.rs index 9911e8d6a..6e3b5f9fb 100644 --- a/crates/voicevox_core/src/infer.rs +++ b/crates/voicevox_core/src/infer.rs @@ -33,16 +33,23 @@ pub(crate) trait InferenceRuntime: 'static { } pub(crate) trait InferenceDomainGroup: Sized { - type Map: InferenceDomainMap; + type Map: InferenceDomainMap; } -pub(crate) trait InferenceDomainMap { +pub(crate) trait InferenceDomainMap { type Group: InferenceDomainGroup; + type Association: InferenceDomainAssociation; - fn any(&self, p: impl InferenceDomainAssociationTargetPredicate) -> bool; + fn any( + &self, + p: impl InferenceDomainAssociationTargetPredicate, + ) -> bool; fn try_ref_map< - F: InferenceDomainAssociationTargetFunction, + F: InferenceDomainAssociationTargetFunction< + Group = Self::Group, + InputAssociation = Self::Association, + >, >( &self, f: F, diff --git a/crates/voicevox_core/src/infer/domains.rs b/crates/voicevox_core/src/infer/domains.rs index ae0cfc9ab..4dc2a1e2d 100644 --- a/crates/voicevox_core/src/infer/domains.rs +++ b/crates/voicevox_core/src/infer/domains.rs @@ -20,15 +20,22 @@ pub(crate) struct InferenceDomainMapImpl { pub(crate) talk: A::Target, } -impl InferenceDomainMap for InferenceDomainMapImpl { +impl InferenceDomainMap for InferenceDomainMapImpl { type Group = InferenceDomainGroupImpl; + type Association = A; - fn any(&self, p: impl InferenceDomainAssociationTargetPredicate) -> bool { + fn any( + &self, + p: impl InferenceDomainAssociationTargetPredicate, + ) -> bool { p.test(&self.talk) } fn try_ref_map< - F: InferenceDomainAssociationTargetFunction, + F: InferenceDomainAssociationTargetFunction< + Group = Self::Group, + InputAssociation = Self::Association, + >, >( &self, f: F, diff --git a/crates/voicevox_core/src/infer/status.rs b/crates/voicevox_core/src/infer/status.rs index 50157ba1b..dacb27569 100644 --- a/crates/voicevox_core/src/infer/status.rs +++ b/crates/voicevox_core/src/infer/status.rs @@ -230,7 +230,7 @@ impl LoadedModels { .unwrap(); panic!( "missing session set for `{type_name}` (should be checked in \ - `ensure_acceptable`)", + `ensure_acceptable` and `ids_for`)", ); }); session_set.get() diff --git a/crates/voicevox_core_macros/src/lib.rs b/crates/voicevox_core_macros/src/lib.rs index 78799d433..98a2fdc5c 100644 --- a/crates/voicevox_core_macros/src/lib.rs +++ b/crates/voicevox_core_macros/src/lib.rs @@ -21,6 +21,7 @@ use syn::parse_macro_input; /// /// impl InferenceDomain for TalkDomain { /// type Operation = TalkOperation; +/// // ... /// } /// /// #[derive(Clone, Copy, Enum, InferenceOperation)]