title: Swift 3 access of private properties in a struct from a extension
body: <p>I've been looking through the swift docs and working through some examples around encapsulation, and am unsure about the behaviour that I'm seeing. I've looked for similar questions on stack, looked through the doc and looked through some tutorials (see the link below) and although this is a trivial question can't find an answer (possibly as Swift has changed?)</p>
  
  <p>Creating a simple Struct representing a queue:</p>
  
  <pre><code>struct Queue&lt;Element&gt; {
  private var elements = [Element]()
  mutating func enqueue(newElement: Element) {
      elements.append(newElement)
  }
  
  mutating func dequeue() -&gt; Element? {
      guard !elements.isEmpty else {
          return nil
      }
      return elements.remove(at: 0)
  }
  }
  </code></pre>
  
  <p>Is later extended by:</p>
  
  <pre><code>extension Queue {
  func peek() -&gt; Element? {
      return elements.first
  }
  }
  </code></pre>
  
  <p>But of course elements is inaccessible due to the private protection level.
  It works by changing the access of elements to fileprivate - but why?</p>
  
  <p>My understanding was that extensions were part of the enclosing type, and looking around the web it seems that is <em>used</em> to work this way <a href="https://www.andrewcbancroft.com/2015/04/22/3-nuances-of-swift-extensions/" rel="noreferrer">https://www.andrewcbancroft.com/2015/04/22/3-nuances-of-swift-extensions/</a></p>
  
  <p>So is my understanding of visibility wrong, or has Swift changed?</p>