I tried to create a linked list with struct
(I know it can be done with enum
s or class
es), and here is my attempt:
struct LinkedListStruct<T> {
let head: T
var tail: UnsafeMutablePointer<LinkedListStruct<T>>
}
it compiles fine, but when I try to use it in a very simple way:
let list = LinkedListStruct(head: 1, tail: nil)
print("End")
"End"
will never be printed out to the console. At the debug navigator view, the cpu usage is at 0% and the memory is not increasing, so I assume that it is not due to recursion. What's wrong with this implementation?