protocol OutputStreamType `文本输出流`
{
mutating func write(_ string: String)
}
protocol Streamable `可以被输出`
{
func writeTo<Target : OutputStreamType>(inout _ target: Target)
}
protocol CustomDebugStringConvertible `调试用自定义字符串`
{
var debugDescription: String { get }
}
protocol Hashable `哈希值`
{
var hashValue: Int { get }
}
protocol StringInterpolationConvertible `可以被\()`
{
init(stringInterpolation strings: Self...)
init<T>(stringInterpolationSegment expr: T)
}
protocol UnicodeScalarLiteralConvertible
{
associatedtype UnicodeScalarLiteralType
init(unicodeScalarLiteral value: Self.UnicodeScalarLiteralType)
}
protocol Comparable `可以被比较`
{
func <(lhs: Self, rhs: Self) -> Bool
func ==(lhs: Self, rhs: Self) -> Bool
}
enum Process `进程参数`
{
static var argc: CInt { get }
static let arguments: [String]
static var unsafeArgv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>> { get }
}
protocol CollectionType `可以被索引`
{
var count: Self.Index.Distance { get }
var first: Self.Generator.Element? { get }
var isEmpty: Bool { get }
func generate() -> Self.Generator
@warn_unused_result func prefixThrough(_ position: Self.Index) -> Self.SubSequence
@warn_unused_result func prefixUpTo(_ end: Self.Index) -> Self.SubSequence
@warn_unused_result func suffixFrom(_ start: Self.Index) -> Self.SubSequence
subscript (_ bounds: Range<Self.Index>) -> Self.SubSequence { get }
subscript (_ position: Self.Index) -> Self.Generator.Element { get }
}
protocol CVarArgType {} `C 可变参数`
{
}
Swift 协议详解
最新推荐文章于 2022-09-04 14:21:06 发布