我需要快速制作一个多级标记器,为此,我决定制作一个协议,要求该协议的采用者为字符序列。这样
protocol TokenProtocol where Self: Sequence, Self.Item == Character {
//any token must consist of characters
var characterRepresentation: [Character] { get }
//but not all tokens may consist of multiple words
var wordRepresentaion: [String]? { get }
}
但是它引起了一个编译错误,即'Item' is not a member type of 'Self'
我做错了吗?实现此目的的最佳方法是什么?
用Self.Item
替换Self.Element
。