Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
use array implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
hartbit committed Feb 15, 2017
1 parent 2dfc6dd commit e3a3927
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Sources/Unbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,11 @@ extension Set: UnboxableCollection {
public typealias UnboxValue = Element

public static func unbox<T: UnboxCollectionElementTransformer>(value: Any, allowInvalidElements: Bool, transformer: T) throws -> Set? where T.UnboxedElement == UnboxValue {
guard let array = value as? [T.UnboxRawElement] else {
guard let array = try [UnboxValue].unbox(value: value, allowInvalidElements: allowInvalidElements, transformer: transformer) else {
return nil
}

return try Set(array.enumerated().map(allowInvalidElements: allowInvalidElements) { index, element in
try transformer.unbox(element: element, allowInvalidCollectionElements: allowInvalidElements).orThrow(UnboxPathError.invalidArrayElement(element, index))
})

return Set(array)
}
}

Expand Down

0 comments on commit e3a3927

Please sign in to comment.