Slather logo

Coverage for "InPlaceTransformingAnyContext.swift" : 100.00%

(7 of 7 relevant lines covered)

RouteComposer/Classes/Router/Internal/InPlaceTransformingAnyContext.swift

1
//
2
// RouteComposer
3
// InPlaceTransformingAnyContext.swift
4
// https://github.com/ekazaev/route-composer
5
//
6
// Created by Eugene Kazaev in 2018-2022.
7
// Distributed under the MIT license.
8
//
9
// Become a sponsor:
10
// https://github.com/sponsors/ekazaev
11
//
12
13
import Foundation
14
15
struct InPlaceTransformingAnyContext: AnyContext {
16
    let context: AnyContext
17
    let transformer: AnyContextTransformer
18
19
    init(context: AnyContext, transformer: AnyContextTransformer) {
30x
20
        self.context = context
30x
21
        self.transformer = transformer
30x
22
    }
30x
23
24
    func value<Context>() throws -> Context {
42x
25
        return try transformer.transform(context)
42x
26
    }
42x
27
}