Nested struct inside another struct, not the same as standalone struct?

So I just learned I can have static properties inside a generic type by using computed property.

So my first example can be:

struct Foo<content: Hashable> {
    struct Holder {
        static var x: Int { 0 }
    }
}

with this, my generic SwiftUI.View can directly implement PreferenceKey. So I can avoid defining free standing PreferenceKey and refer to its Type as Self.self

1 Like