// // Component+Access.swift // // // Created by Christian Treffs on 25.06.19. // #if swift(>=5.1) @dynamicMemberLookup public struct ReadableOnly where Comp: Component { @usableFromInline let component: Comp public init(_ component: Comp) { self.component = component } @inlinable public subscript(dynamicMember keyPath: KeyPath) -> C { return component[keyPath: keyPath] } } @dynamicMemberLookup public struct Writable where Comp: Component { @usableFromInline let component: Comp public init(_ component: Comp) { self.component = component } @inlinable public subscript(dynamicMember keyPath: ReferenceWritableKeyPath) -> C { nonmutating get { return component[keyPath: keyPath] } nonmutating set { component[keyPath: keyPath] = newValue } } } #endif