在main.rs
中,我创建了一些函数来减少main()
的大小.在它们内部,我使用 struct 及其方法.
fn handle_input() {
// some code
}
fn handle_quit() {
// some code
) {
fn main() {
// handle_handle_input() being is used here
// handle_quit() being is used here
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_handle_input() {
// some code
}
#[test]
fn test_handle_quit() {
// some code
}
}
现在,所有的测试都通过了.然而,main.rs
变得太大了,所以我想将测试放在它们自己的文件中.
既然我不能再use use super::*
岁了,我怎么能做到这一点呢?或者,可能唯一的方法是将这些函数转换为 struct 方法,并将它们导入新的测试文件中?