Files
check-ios-bus/Modules/BusX/Bus/src/Bus.Aux.swift
Михаил Капелько b67ed0c593 d
2023-12-31 19:58:55 +03:00

30 lines
654 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

public extension Bus {
/// Пропускаем далее единственный ключ.
static func convertKeyValue<T>(
_ key: String,
_ v: (key: String, value: Any)
) -> (String, T)? {
guard
key == v.key,
let value = v.value as? T
else {
return nil
}
return (key, value)
}
/// Пропускаем далее множество ключей.
static func convertKeyValue<T>(
_ keys: Set<String>,
_ v: (key: String, value: Any)
) -> (String, T)? {
guard
keys.contains(v.key),
let value = v.value as? T
else {
return nil
}
return (v.key, value)
}
}