@@ -25,14 +25,12 @@ use crate::{
2525
2626impl VoicevoxOnnxruntime {
2727 #[ cfg( feature = "load-onnxruntime" ) ]
28- pub ( crate ) fn lib_versioned_filename ( ) -> & ' static std:: ffi:: CStr {
29- to_cstr ! ( voicevox_core:: blocking:: Onnxruntime :: LIB_VERSIONED_FILENAME )
30- }
28+ pub ( crate ) const LIB_VERSIONED_FILENAME : & ' static std:: ffi:: CStr =
29+ to_cstr ! ( voicevox_core:: blocking:: Onnxruntime :: LIB_VERSIONED_FILENAME ) ;
3130
3231 #[ cfg( feature = "load-onnxruntime" ) ]
33- pub ( crate ) fn lib_unversioned_filename ( ) -> & ' static std:: ffi:: CStr {
34- to_cstr ! ( voicevox_core:: blocking:: Onnxruntime :: LIB_UNVERSIONED_FILENAME )
35- }
32+ pub ( crate ) const LIB_UNVERSIONED_FILENAME : & ' static std:: ffi:: CStr =
33+ to_cstr ! ( voicevox_core:: blocking:: Onnxruntime :: LIB_UNVERSIONED_FILENAME ) ;
3634
3735 #[ ref_cast_custom]
3836 fn new ( rust : & voicevox_core:: blocking:: Onnxruntime ) -> & Self ;
@@ -61,11 +59,11 @@ impl VoicevoxOnnxruntime {
6159#[ cfg( feature = "load-onnxruntime" ) ]
6260macro_rules! to_cstr {
6361 ( $s: expr) => { {
64- const __RUST_STR : & str = $s ;
65- static __C_STR : & [ u8 ] = const_format :: concatcp! ( __RUST_STR , '\0' ) . as_bytes ( ) ;
66-
67- std:: ffi:: CStr :: from_bytes_with_nul ( __C_STR )
68- . unwrap_or_else ( |e| panic! ( "{__RUST_STR:?} should not contain ` \\ 0`: {e}" ) )
62+ static CSTR : & [ u8 ] = const_format :: concatcp! ( $s , '\0' ) . as_bytes ( ) ;
63+ unsafe {
64+ // SAFETY: added a nul with `concatcp!`
65+ std:: ffi:: CStr :: from_bytes_with_nul_unchecked ( CSTR )
66+ }
6967 } } ;
7068}
7169#[ cfg( feature = "load-onnxruntime" ) ]
0 commit comments