mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
f250ad7b40
add rw locks usage
26 lines
567 B
Swift
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)
|
|
}
|
|
}
|