Main2.hx 546 B

12345678910111213141516171819202122232425262728293031
  1. class Main2 {
  2. static function main() {
  3. var foo:Vector<Foo> = null;
  4. var bar:Vector<Bar> = Vector.fromIterable(foo);
  5. }
  6. }
  7. typedef Foo = {
  8. final id:String;
  9. final ?project:String;
  10. }
  11. typedef Bar = {
  12. final id:String;
  13. final createDate:Date;
  14. }
  15. abstract Vector<T>(Array<T>) {
  16. inline function new(a)
  17. this = a;
  18. @:from static function fromVector<T, R:T>(v:Vector<R>):Vector<T>
  19. return cast v;
  20. static public function fromIterable<T, R:T>(v:Iterable<R>):Vector<T>
  21. return null;
  22. @:to public function toArray()
  23. return this.copy();
  24. }