From f79e6855a65e96576a8c983ca26fcc2228298a20 Mon Sep 17 00:00:00 2001 From: Ryo Yamashita Date: Wed, 3 Apr 2024 01:38:51 +0900 Subject: [PATCH] `unsafe impl Send for {Mecab,Njd,JpCommon}` --- crates/open_jtalk/src/jpcommon.rs | 3 +++ crates/open_jtalk/src/mecab/mod.rs | 3 +++ crates/open_jtalk/src/njd.rs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/crates/open_jtalk/src/jpcommon.rs b/crates/open_jtalk/src/jpcommon.rs index d31ad19..7f97c50 100644 --- a/crates/open_jtalk/src/jpcommon.rs +++ b/crates/open_jtalk/src/jpcommon.rs @@ -32,6 +32,9 @@ unsafe impl resources::Resource for JpCommon { } } +// SAFETY: `Send`と対立する性質はないはず。 +unsafe impl Send for JpCommon {} + impl<'a> Iterator for JpCommonLabelFeatureIter<'a> { type Item = &'a str; fn next(&mut self) -> Option { diff --git a/crates/open_jtalk/src/mecab/mod.rs b/crates/open_jtalk/src/mecab/mod.rs index 42fb31c..5f8b81c 100644 --- a/crates/open_jtalk/src/mecab/mod.rs +++ b/crates/open_jtalk/src/mecab/mod.rs @@ -39,6 +39,9 @@ unsafe impl resources::Resource for Mecab { } } +// SAFETY: `Send`と対立する性質はないはず。 +unsafe impl Send for Mecab {} + impl Mecab { unsafe fn as_raw_ptr(&self) -> *mut open_jtalk_sys::Mecab { if self.0.is_none() { diff --git a/crates/open_jtalk/src/njd.rs b/crates/open_jtalk/src/njd.rs index 8928eb1..5dc7533 100644 --- a/crates/open_jtalk/src/njd.rs +++ b/crates/open_jtalk/src/njd.rs @@ -24,6 +24,9 @@ unsafe impl resources::Resource for Njd { } } +// SAFETY: `Send`と対立する性質はないはず。 +unsafe impl Send for Njd {} + impl Njd { pub(crate) unsafe fn as_raw_ptr(&self) -> *mut open_jtalk_sys::NJD { if self.0.is_none() {