Files
swiftpm-mustache/Sources/Mustache/Parent.swift
hummingbird-automation[bot] ec4ef9aa04 Update from Hummingbird Project Template (#58)
* Update from hummingbird-project-template 572d468b2cabeca286314c5a35196bd42445c8ef

* run swift-format

* Remove .swiftformat

---------

Co-authored-by: adam-fowler <adam-fowler@users.noreply.github.com>
Co-authored-by: Adam Fowler <adamfowler71@gmail.com>
2024-11-28 07:31:09 +00:00

26 lines
899 B
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Hummingbird server framework project
//
// Copyright (c) 2021-2021 the Hummingbird authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// Protocol for object that has a custom method for accessing their children, instead
/// of using Mirror
public protocol MustacheParent {
func child(named: String) -> Any?
}
/// Extend dictionary where the key is a string so that it uses the key values to access
/// it values
extension Dictionary: MustacheParent where Key == String {
public func child(named: String) -> Any? { self[named] }
}