   
   public init(dictionaryLiteral elements: (String, Element)...) {
     self.elements = elements
+  }
+
+  /// Construct a copy of `other`
+  ///
+  /// exists primarily so a Dictionary literal can be passed as an argument
+  public init(_ other: LabeledStructure) {
+    self.elements = other.elements
   }
   
   public init(_ elements: [(String, Element)]) {

  struct Zee2 : CustomReflectable {
    func reflect() -> Mirror {
      return Mirror(
        ["bark": 1, "bite": 0] as LabeledStructure, schema: .Dictionary)
    }
  }
  let z2 = Zee2().reflect()
  expectEqual(.Dictionary, z2.schema)
  expectEqual("[bark: 1, bite: 0]", z2.description)
}


runAllTests()

  public let schema: Schema?
}


extension Mirror {
  internal struct LegacyChildren : CollectionType {
    init(_ oldMirror: MirrorType) {
      self._oldMirror = oldMirror
    }
    var startIndex: Int { return 0 }
    var endIndex: Int { return _oldMirror.count }
    subscript(position: Int) -> Child {
      let (label, childMirror) = _oldMirror[position]
      return (label: label, value: childMirror.value)
    }
    func generate() -> IndexingGenerator<LegacyChildren> {
      return IndexingGenerator(self)
    }
    internal let _oldMirror: MirrorType
  }
  
  public init(_ oldMirror: MirrorType) {
    self.init(
      structure: LegacyChildren(oldMirror),
      schema: oldMirror.disposition)
  }
}

public protocol CustomReflectable {
  func reflect() -> Mirror
}

func reflect(x: Any) -> Mirror {
  if let customized? = x as? CustomReflectable {
    return customized.reflect()
  }
  else {
    return Mirror(Swift.reflect(x))
  }
}

//===--- Addressing -------------------------------------------------------===//
public protocol MirrorPathType {}
extension IntMax : MirrorPathType {}
extension Int : MirrorPathType {}
extension String : MirrorPathType {}

enum MirrorPathElement {
case Offset(IntMax)
case Label(String)
  init(_ x: MirrorPathType) {
    switch x {
    case let a as IntMax:
      self = .Offset(a)
    case let a as Int:
      self = .Offset(IntMax(a))
    case let a as String:
      self = .Label(a)
    default:
      _preconditionFailure("unknown MirrorPathType")
    }
  }
}

/// Returns the first index `i` in `indices(domain)` such that
/// `predicate(domain[i])` is `true``, or `nil` if
/// `predicate(domain[i])` is `false` for all `i`.
///
/// Complexity: O(\ `count(domain)`\ )
public func find<
  C: CollectionType
>(domain: C, predicate: (C.Generator.Element)->Bool) -> C.Index? {
  for i in indices(domain) {
    if predicate(domain[i]) {
      return i
    }
  }
  return nil
}

extension Mirror {
  struct _Dummy : CustomReflectable {
    var mirror: Mirror
    func reflect() -> Mirror { return mirror }
  }
  
  func address(first: MirrorPathType, _ rest: MirrorPathType...) -> Any? {
    var result: Any = _Dummy(mirror: self)
    for e in [first] + rest {
      let structure = reflect(result).structure
      let position: Structure.Index
      switch MirrorPathElement(e) {
      case .Offset(let n):
        position = advance(structure.startIndex, n, structure.endIndex)
      case .Label(let l):
        position = find(structure) { $0.label == l } ?? structure.endIndex
      }
      if position == structure.endIndex { return nil }
      result = structure[position].value
    }
    return result
  }
}

//===--- Adapters ---------------------------------------------------------===//
