示例工程 14-access-control-modules

14-access-control-modules/Sources/Ch14Demo/App.swift

swift · 1.0 KB

import Ch14Kit
import Ch14Support
 
final class SavingsLedger: Ledger {
    override var label: String {
        "savings"
    }
}
 
@main
struct Ch14Demo {
    static func main() {
        let account = Account(name: "ada", internalID: 7, secret: "hidden", token: "token-123")
        print("[14.1] public = \(account.name)")
        print("[14.1] public 计算属性 = \(account.publicDescription)")
        print("[14.2] package = \(account.packageFingerprint)")
        print("[14.2] 跨 target = \(Support.describe(account))")
 
        let ledger: Ledger = SavingsLedger()
        print("[14.3] open 子类 = \(ledger.describe())")
 
        let closed = ClosedLedger()
        print("[14.4] public 类 = \(closed.label)/\(String(describing: type(of: closed)))")
 
        print("[14.5] MemoryLayout<Account> = \(MemoryLayout<Account>.size) 字节")
        print("[14.5] MemoryLayout<Ledger> = \(MemoryLayout<Ledger>.size) 字节")
        print("[14.5] String(describing:) = \(String(describing: type(of: account)))")
    }
}