Skip to content
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

rust初学者,关于包、crate和模块的问题求解答 #2

Closed
aidenup opened this issue Aug 10, 2022 · 2 comments
Closed

rust初学者,关于包、crate和模块的问题求解答 #2

aidenup opened this issue Aug 10, 2022 · 2 comments

Comments

@aidenup
Copy link

aidenup commented Aug 10, 2022

你好,我是rust 初学者,现在有个问题不知是否可以在这里请教下:
在两个crate 中,如何互相引用各自的mod,例如在lib.rs 中定义的mod 想要在main.rs 中使用。
尝试过使用crate:: , 但是这个根只负责main.rs下,也尝试过将模块拆分成文件,但应该不是我想要的结果 ⬇️

// main.rs
mod foront_of_house;
fn main() {
}
// foront_of_house.rs
pub mod serving {
  ...
}

希望能得到解答,谢谢~

@WumaCoder
Copy link
Collaborator

crate:: 换成你的包名试试,我写了一个例子就在这个仓库里

@aidenup
Copy link
Author

aidenup commented Aug 11, 2022 via email

@aidenup aidenup closed this as completed Aug 13, 2022
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

No branches or pull requests

2 participants