[英]Rust bin accessing modules
無法從/src/bin/client.rs
訪問/src/gameclient/server_connection.rs
中的ServerConnection
。
我沒有任何lib.rs
或main.rs
所有二進制文件都在/src/bin/
Cargo.toml
...
[[bin]]
name = "server"
path = "src/bin/server.rs"
[[bin]]
name = "client"
path = "src/bin/client.rs"
...
/src/gameclient/mod.rs
rust-analyzer 已經在這里抱怨:
文件未包含在模塊樹中
pub mod player_instance;
pub use crate::gameclient::player_instance::PlayerInstance;
pub mod server_connection;
pub use crate::gameclient::server_connection::ServerConnection;
/src/gameclient/server_connection/ServerConnection
...
pub struct ServerConnection {
pub server_endpoint: url::Url,
}
pub impl ServerConnection {
pub fn connect(&self) {
...
Pitaj已經給出了正確的答案。
只是為了完整性。
在最頂部添加這個讓我擺脫了 lib.rs。
#[path = "../gameclient/mod.rs"]
mod gameclient;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.