Skip to content

Commit 3e890c6

Browse files
committed
Work around type inference issue in varray![]
When passing &varray[...] to a method accepting &OutArray, rustc will fail compilation, as the involved types don't seem to be eligible for auto-deref coercion. The explicit `as` cast gives the compiler the necessary type hints.
1 parent 3416265 commit 3e890c6

File tree

1 file changed

+2
-1
lines changed
  • godot-core/src/builtin/collections

1 file changed

+2
-1
lines changed

godot-core/src/builtin/collections/array.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,8 @@ macro_rules! varray {
16251625
array.push(&$elements.to_variant());
16261626
)*
16271627
array
1628-
}
1628+
} as $crate::builtin::VariantArray
1629+
// The `as` cast is necessary for Deref coercion to OutArray; type inference doesn't seem to pick it up otherwise.
16291630
};
16301631
}
16311632

0 commit comments

Comments
 (0)