在我的 main.rs 中,我可以很好地完成代码。但我没有在我的模块文件中得到它。
我的文件夹结构如下所示:
src/
|___game_components/
| |___card.rs
|___game_components.rs
|___main.rs
Run Code Online (Sandbox Code Playgroud)
该程序构建并运行得很好(除了一些未使用的警告)。str当编辑我的 main.rs 文件时,我得到了,rand和我的结构的代码完成Card。然而,当编辑我的任一 card.rs 时,我根本没有得到任何代码完成,甚至对于该文件中定义的 Card 结构也是如此。
我尝试重新安装 rust-analyzer 并运行rustup update,但没有运气。
我错过了什么,或者某个地方有错误吗?
编辑:添加文件内容
主要.rs:
pub mod game_components;
use game_components::card::Card;
fn main() {
println!("{:?}", Card::new(5));
}
Run Code Online (Sandbox Code Playgroud)
游戏组件.rs:
pub mod card;
Run Code Online (Sandbox Code Playgroud)
卡.rs:
const FACES: [&str; 13] = [
"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace",
];
const SUITS: [&str; 4] = ["Hearts", "Clubs", "Diamonds", "Spades"];
#[derive(Debug)]
pub struct …Run Code Online (Sandbox Code Playgroud)