我有这样的文件层次 struct :
main.rs
protocol/
protocol/mod.rs
protocol/struct.rs
struct.rs
年:
pub struct Struct {
members: i8
}
impl Struct {
pub fn new() -> Struct {
Struct { 4 }
}
}
我如何访问它,因为:
mod protocol;
protocol::Struct::new();
// As opposed to:
// protocol::struct::Struct::new();
我try 过pub
、use
和mod
的各种组合,但不可否认,我是在盲目地戳东西.
有没有可能在不创建新mod的情况下将一个struct(它是impl
)拆分成一个单独的文件?