File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88use godot_ffi as sys;
99
10- use crate :: builtin;
1110use crate :: builtin:: { Variant , VariantType } ;
1211use crate :: global:: PropertyUsageFlags ;
1312use crate :: meta:: error:: ConvertError ;
@@ -16,6 +15,7 @@ use crate::meta::{
1615} ;
1716use crate :: registry:: method:: MethodParamOrReturnInfo ;
1817use crate :: registry:: property:: builtin_type_string;
18+ use crate :: { builtin, meta} ;
1919
2020// Re-export sys traits in this module, so all are in one place.
2121#[ rustfmt:: skip] // Do not reorder.
@@ -213,6 +213,25 @@ pub trait ArrayElement: ToGodot + FromGodot + sealed::Sealed + 'static {
213213 }
214214}
215215
216+ pub trait ElementLiteral {
217+ type Element ;
218+ fn to_element ( & self ) -> Self :: Element ;
219+ }
220+
221+ impl < T > ElementLiteral for T
222+ where
223+ T : ToGodot < Pass = meta:: ByValue > + Copy ,
224+ {
225+ type Element = T ;
226+ fn to_element ( & self ) -> Self :: Element {
227+ * self
228+ }
229+ }
230+
231+ pub fn elem < T : ElementLiteral > ( element : & T ) -> T :: Element {
232+ element. to_element ( )
233+ }
234+
216235// ----------------------------------------------------------------------------------------------------------------------------------------------
217236// Non-polymorphic helper functions, to avoid constant `<T::Via as GodotType>::` in the code.
218237
You can’t perform that action at this time.
0 commit comments