8000 [Rust]is_model_loadedを実装した by qwerty2501 · Pull Request #151 · VOICEVOX/voicevox_core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Rust]is_model_loadedを実装した #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

qwerty2501
Copy link
Contributor

内容

id_model_loaded関数を実装しました

関連 Issue

refs #128

その他

@qwerty2501 qwerty2501 changed the base branch from main to rust June 7, 2022 13:25
Comment on lines 57 to 67
pub fn is_model_loaded(speaker_id: i64) -> bool {
unimplemented!()
if let Some(status) = STATUS.lock().unwrap().as_ref() {
status.is_model_loaded(speaker_id as usize)
} else {
false
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この関数について、グローバル変数の状態によってテスト結果が変わってしまうためテストが書きにくい状態になっています

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

オブジェクト指向的にはis_model_loadedもSTATUSも同じクラスに含めてしまってシングルトンクラスとしちゃえばテストも書けそうなのですが、Rustだとどうするのが良いんだろう。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ちょっと意図が読めないのですが、
シングルトンもグローバル変数もstatic領域に配置してることには変わりないので他のテストの影響を受けてしまうのは変わらないと思います

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static変数を使う部分をテストすることはできないと諦めて、static変数を使う部分と処理をするコードに分けて、後者だけテストするのを意図しています。
その方法の1つがクラス化&シングルトンかなと思った次第です。
#150 (comment) と似ています。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

やるにしてもまとめてやったほうがよさそうですね

@qwerty2501 qwerty2501 changed the title id_model_loadedを実装した [Rust]id_model_loadedを実装した Jun 7, 2022
Copy link
Member
@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

間違えました・・・

@qwerty2501 qwerty2501 changed the title [Rust]id_model_loadedを実装した [Rust]is_model_loadedを実装した Jun 7, 2022
@qwerty2501 qwerty2501 force-pushed the feature/implements-is_model_loaded branch from d3f4e84 to 845a491 Compare June 7, 2022 17:52
Copy link
Member
@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

Copy link
Member
@PickledChair PickledChair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@PickledChair PickledChair merged commit 50404bc into VOICEVOX:rust Jun 8, 2022
qwerty2501 added a commit to qwerty2501/voicevox_core that referenced this pull request Jul 23, 2022
* is_model_loadedを実装した

* is_model_loadedに渡す数値をspeaker_idではなくmodel_indexにした
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0