mhandles.nim 271 B

1234567891011121314151617181920
  1. type
  2. FD* = distinct cint
  3. type
  4. AnyFD* = concept fd
  5. close(fd)
  6. proc close*(fd: FD) =
  7. discard
  8. type
  9. Handle*[T: AnyFD] = object
  10. fd: T
  11. proc close*[T: AnyFD](h: var Handle[T]) =
  12. close h.fd
  13. proc initHandle*[T: AnyFD](fd: T): Handle[T] =
  14. Handle[T](fd: fd)