抽象工厂解决了在不指定具体类的情况下创建整个产品系列的问题。 抽象工厂的抽象接口: lib.rs pub trait Button {
fn press(&self);
}
pub trait Checkbox {
fn switch (&self);
}
/// 抽象工厂是通过泛型实现的,它允许编译器创建一个不需要在运行时进行动态调度的代码。
pub trait GuiFactory {
type B: Button;
type C: Checkbox;
fn create_button(&..