Open1
Swiftはプロトコルにスタティックメゾットを宣言できるからインスタンスでDIするのではなくジェネリクスの型パラメーターでDI可能

protocol HogeProtocol {
static func a() -> Int
}
struct Hoge: HogeProtocol {
static func a() -> Int { 1 }
}
struct Hoge2: HogeProtocol {
static func a() -> Int { 2 }
}
final class VieweModel<Hoge: HogeProtocol> {
func x() -> Int {
Hoge.a()
}
}
let viewModel: VieweModel<Hoge> = .init()
print(viewModel.x())
let viewModel2: VieweModel<Hoge2> = .init()
print(viewModel2.x())