mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
26 lines
723 B
Swift
26 lines
723 B
Swift
//
|
|
// CharacterSet+LinuxHack.swift
|
|
// SwiftLint
|
|
//
|
|
// Created by Marcelo Fabri on 12/25/16.
|
|
// Copyright © 2016 Realm. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension CharacterSet {
|
|
func isSuperset(ofCharactersIn string: String,
|
|
union other: CharacterSet = CharacterSet()) -> Bool {
|
|
#if swift(>=3.2)
|
|
let set = union(other)
|
|
return set.isSuperset(of: CharacterSet(charactersIn: string))
|
|
#else
|
|
// workaround for https://bugs.swift.org/browse/SR-3485
|
|
return !Set(string.characters).contains { character in
|
|
let scalar = String(character).unicodeScalars.first!
|
|
return !contains(scalar) && !other.contains(scalar)
|
|
}
|
|
#endif
|
|
}
|
|
}
|