Is it possible to subclass a generic struct in swift ?
assume we have a struct:
struct Foo<T> {}
and I wana "subclass" it to add some functionality:
struct Something {}
struct Bar<F>: Foo<Something> { /*<<<= ERROR: Inheritance from non-protocol type 'Foo<Something>' */
let store: Something
let someF: F
}
If you replace struct with class this example works.
class Foo<T> {}
//struct Bar1<T>: Foo<T> { /* Inheritance from non-protocol type 'Foo<T>' */
// let name = "Bar"
//}
class Something {}
class Bar<F>: Foo<Something> { /* Inheritance from non-protocol type 'Foo<Something>' */
let store: F?
init(value: F?) {
self.store = value
}
}
Any idea how to make this work for structs ?
I'm trying to stick to value types but swift is making it hard.