11use std:: fmt;
22
3- #[ cfg( all ( any ( feature = "luau" , doc ) , feature = " serialize") ) ]
3+ #[ cfg( feature = "serialize" ) ]
44use serde:: ser:: { Serialize , SerializeTupleStruct , Serializer } ;
55
6- use super :: LuaType ;
7-
86/// A Luau vector type.
97///
108/// By default vectors are 3-dimensional, but can be 4-dimensional
@@ -23,6 +21,7 @@ impl fmt::Display for Vector {
2321 }
2422}
2523
24+ #[ cfg_attr( not( feature = "luau" ) , allow( unused) ) ]
2625impl Vector {
2726 pub ( crate ) const SIZE : usize = if cfg ! ( feature = "luau-vector4" ) { 4 } else { 3 } ;
2827
@@ -67,7 +66,7 @@ impl Vector {
6766 }
6867}
6968
70- #[ cfg( all ( any ( feature = "luau" , doc ) , feature = " serialize") ) ]
69+ #[ cfg( feature = "serialize" ) ]
7170impl Serialize for Vector {
7271 fn serialize < S : Serializer > ( & self , serializer : S ) -> std:: result:: Result < S :: Ok , S :: Error > {
7372 let mut ts = serializer. serialize_tuple_struct ( "Vector" , Self :: SIZE ) ?;
@@ -87,11 +86,7 @@ impl PartialEq<[f32; Self::SIZE]> for Vector {
8786 }
8887}
8988
90- impl LuaType for Vector {
91- #[ cfg( feature = "luau" ) ]
92- const TYPE_ID : i32 = ffi:: LUA_TVECTOR ;
93-
94- // This is a dummy value, as `Vector` is supported only by Luau
95- #[ cfg( not( feature = "luau" ) ) ]
96- const TYPE_ID : i32 = ffi:: LUA_TNONE ;
89+ #[ cfg( feature = "luau" ) ]
90+ impl crate :: types:: LuaType for Vector {
91+ const TYPE_ID : std:: os:: raw:: c_int = ffi:: LUA_TVECTOR ;
9792}
0 commit comments