texplicit_move.nim 265 B

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