mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
36 lines
888 B
Swift
36 lines
888 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) -> Bool {
|
|
#if os(Linux)
|
|
// workaround for https://bugs.swift.org/browse/SR-3485
|
|
let chars = Set(string.characters)
|
|
for char in chars where !contains(char.unicodeScalar) {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
#else
|
|
let otherSet = CharacterSet(charactersIn: string)
|
|
return isSuperset(of: otherSet)
|
|
#endif
|
|
}
|
|
}
|
|
|
|
private extension Character {
|
|
var unicodeScalar: UnicodeScalar {
|
|
let characterString = String(self)
|
|
let scalars = characterString.unicodeScalars
|
|
|
|
return scalars[scalars.startIndex]
|
|
}
|
|
}
|