Skip to content

Commit

Permalink
Make KeyPath functions/properties public.
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerluan committed May 28, 2022
1 parent 0db2135 commit 914d782
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/KeyPath.swift
Expand Up @@ -5,17 +5,17 @@ import Foundation
/// Simple struct used to represent multiple segments of a string.
/// This is a utility used to recursively access values in nested dictionaries.
public struct KeyPath {
var segments: [String]
public var segments: [String]

var isEmpty: Bool { return segments.isEmpty }
var path: String {
public var isEmpty: Bool { return segments.isEmpty }
public var path: String {
return segments.joined(separator: ".")
}

/// Strips off the first segment and returns a pair
/// consisting of the first segment and the remaining key path.
/// Returns nil if the key path has no segments.
func headAndTail() -> (head: String, tail: KeyPath)? {
public func headAndTail() -> (head: String, tail: KeyPath)? {
guard !isEmpty else { return nil }
var tail = segments
let head = tail.removeFirst()
Expand Down

0 comments on commit 914d782

Please sign in to comment.