From 695c0a9d83cbf75a0e59fbc9dea9192157530ae5 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Tue, 17 Sep 2024 19:19:32 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AF=E3=83=AD=E3=83=BC=E3=82=BA=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=A6=E3=82=82`Drop`=E3=81=8C=E8=AD=A6=E5=91=8A?= =?UTF-8?q?=E3=82=92=E5=87=BA=E3=81=99=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/voicevox_core_python_api/src/lib.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/voicevox_core_python_api/src/lib.rs b/crates/voicevox_core_python_api/src/lib.rs index cc4cd991b..6c16cabff 100644 --- a/crates/voicevox_core_python_api/src/lib.rs +++ b/crates/voicevox_core_python_api/src/lib.rs @@ -182,13 +182,15 @@ impl Closable { impl Drop for Closable { fn drop(&mut self) { - warn!( - "デストラクタにより`{}`のクローズが行われます。可能な限り`{}`でクローズするようにして\ - 下さい", - C::NAME, - A::EXIT_METHOD - ); - *self.content.blocking_write_() = MaybeClosed::Closed; + let content = mem::replace(&mut *self.content.blocking_write_(), MaybeClosed::Closed); + if matches!(content, MaybeClosed::Open(_)) { + warn!( + "デストラクタにより`{}`のクローズが行われました。通常は、可能な限り`{}`でクローズ\ + するようにして下さい", + C::NAME, + A::EXIT_METHOD, + ); + } } }