Just came across this.
I want to be able to hold onto the reference to a subscript "method" for later
use.
Assigning the subscript to a var in the init of a type raises a segmentation
fault.
Should this - could this - be allowed?
protocol DataProvider
{
associatedtype ItemType
subscript(index: Int) -> ItemType { get }
}
struct AnyDataProvider<providerType: DataProvider> : DataProvider
{
private var _subscript: (Int) -> providerType.ItemType
subscript(index: Int) -> providerType.ItemType
{
return _subscript(index)
}
init<P : DataProvider>(_ base: P) where P.ItemType == providerType.ItemType
{
_subscript = base.subscript
}
}
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution