I am trying to use protocols to give specific specifications to the structures that will implement them, but I need to be able to create these common ones.
For instance:
protocol NodeType {
}
protocol EdgeType {
var fromNode: NodeType
var toNode: NodeType
}
The problem is that both nodes can be different types of structures that implement the implementation of the NodeType protocol
In an ideal world, I need the following:
protocol EdgeType<T: NodeType> {
var fromNode: T
var toNode: T
}
to make sure that both nodes are the same class or structural type
Is something like this currently fast? thanks in advance
source
share