我做了一个最小的例子。在lib.rs:
mod sealed {
pub enum Choice {
A,
B,
}
}
pub fn print_choice(choice: sealed::Choice) {
match choice {
sealed::Choice::A => println!("Choice A"),
sealed::Choice::B => println!("Choice B"),
}
}
Run Code Online (Sandbox Code Playgroud)
我认为:枚举Choice是公共的。然而,它处于私人模式中,无法从板条箱外部访问。因此该函数print_choice根本不可调用。
我的想法有什么问题吗?
rust ×1