texplicit_move.nim 281 B

12345678910111213141516171819202122232425262728293031
  1. discard """
  2. output: '''3
  3. 0
  4. 0
  5. 10
  6. destroyed!
  7. '''
  8. joinable: false
  9. """
  10. type
  11. myseq* = object
  12. f: int
  13. proc `=destroy`*(x: var myseq) =
  14. echo "destroyed!"
  15. var
  16. x: myseq
  17. x.f = 3
  18. echo move(x.f)
  19. echo x.f
  20. # bug #9743
  21. let a = create int
  22. a[] = 10
  23. var b = move a[]
  24. echo a[]
  25. echo b