Files
divkit/client/ios/Core/Base/NonEmpty+Set.swift
T
babaevmm f250ad7b40 open rw locks pr
add rw locks usage
2022-09-26 16:41:40 +03:00

26 lines
567 B
Swift

// Copyright 2021 Yandex LLC. All rights reserved.
public typealias NonEmptySet<Element: Hashable> = NonEmpty<Set<Element>>
extension NonEmpty {
@inlinable
public init?<E: Hashable>(set: C) where C == Set<E> {
guard let head = set.first else {
return nil
}
self.init(head, Set(set.dropFirst()))
}
@inlinable
public init<E: Hashable>(set head: E, _ tail: E...) where C == Set<E> {
self.init(head, Set(tail))
}
}
extension NonEmpty where Element: Hashable {
@inlinable
public func asSet() -> Set<Element> {
Set(self)
}
}