Skip to content
You can open Any to <T> or <T: Equatable> by using runtime magic.
Swift
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.swiftpm/xcode/package.xcworkspace wip Jan 9, 2020
Sources/EquatableOpen wip Linux Jan 10, 2020
Tests wip Linux Jan 10, 2020
.gitignore wip Jan 9, 2020
Package.swift
README.md Update README.md Jan 10, 2020

README.md

EquatableOpen

You can open Any to <T> or <T: Equatable> by using runtime magic.

API

anyIsEqual

func anyIsEqual(_ a: Any, _ b: Any) -> Bool

It calls == if type of a and b are Equatable. It returns false if not.

openEquatable

public protocol EquatableOpener {
    init<T>(_ value: T)
    init<T: Equatable>(_ value: T)
}

func openEquatable<EO: EquatableOpener>(_ anyValue: Any, openerType: EO.Type) -> EO

You can open Any. It calls corresponding init to whether type of anyValue is Equatable.

You can build AnyEquatable(see below) as custom implementation on it.

Platforms

macOS

iOS

Linux

  • $ swift test -Xlinker -export-dynamic

Examples

You can’t perform that action at this time.