Skip to content

Commit

Permalink
Renamed _Indexed to _IndexedProtocol
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitribouniol committed Jun 12, 2023
1 parent 1b56bf8 commit acf0422
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ extension DatastoreDescriptor {

for child in mirror.children {
guard let label = child.label else { continue }
guard let childValue = child.value as? any _Indexed else { continue }
guard let childValue = child.value as? any _IndexedProtocol else { continue }

let actualKey: String
if label.prefix(1) == "_" {
Expand Down
8 changes: 4 additions & 4 deletions Sources/CodableDatastore/Indexes/Indexed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public struct Indexed<T> where T: Indexable {
/// You should not reach for this directly, and instead use the @``Indexed`` property wrapper.
public struct _AnyIndexed {
var indexedType: String
var indexed: any _Indexed
var indexed: any _IndexedProtocol

init<T>(indexed: Indexed<T>) {
self.indexed = indexed
Expand All @@ -97,7 +97,7 @@ public struct _AnyIndexed {
}

/// An internal protocol to use when evaluating types for indexed properties.
protocol _Indexed<T>: Indexable {
protocol _IndexedProtocol<T>: Indexable {
associatedtype T: Indexable

init(wrappedValue: T)
Expand All @@ -106,7 +106,7 @@ protocol _Indexed<T>: Indexable {
var projectedValue: _AnyIndexed { get }
}

extension _Indexed {
extension _IndexedProtocol {
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
let wrappedValue = try container.decode(T.self)
Expand All @@ -123,5 +123,5 @@ extension _Indexed {
public static func == (lhs: Self, rhs: Self) -> Bool { lhs.wrappedValue == rhs.wrappedValue }
}

extension Indexed: _Indexed {
extension Indexed: _IndexedProtocol {
}
4 changes: 2 additions & 2 deletions Tests/CodableDatastoreTests/IndexedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class IndexedTests: XCTestCase {
// for child in mirror.children {
// guard let label = child.label else { continue }
// let childType = type(of: child.value)
// guard childType is _Indexed.Type else { continue }
// guard childType is _IndexedProtocol.Type else { continue }
// print("Child: \(label), type: \(childType)")
// indexedProperties.append(label)
// }
Expand All @@ -61,7 +61,7 @@ final class IndexedTests: XCTestCase {
for child in mirror.children {
guard let label = child.label else { continue }
let childType = type(of: child.value)
guard childType is any _Indexed.Type else { continue }
guard childType is any _IndexedProtocol.Type else { continue }
indexedProperties.append(label)
}
XCTAssertEqual(indexedProperties, ["_name", "_age"])
Expand Down

0 comments on commit acf0422

Please sign in to comment.