Skip to content

Commit 65ce2c3

Browse files
committed
Consistent #[derive] order + smaller formatting
1 parent 1cba82c commit 65ce2c3

File tree

21 files changed

+73
-42
lines changed

21 files changed

+73
-42
lines changed

godot-core/src/builtin/array.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,17 +597,17 @@ unsafe impl<T: VariantMetadata> GodotFfi for Array<T> {
597597
fn move_return_ptr;
598598
}
599599

600-
unsafe fn from_arg_ptr(ptr: sys::GDExtensionTypePtr, _call_type: sys::PtrcallType) -> Self {
601-
let array = Self::from_sys(ptr);
602-
std::mem::forget(array.share());
603-
array
604-
}
605-
606600
unsafe fn from_sys_init_default(init_fn: impl FnOnce(sys::GDExtensionTypePtr)) -> Self {
607601
let mut result = Self::default();
608602
init_fn(result.sys_mut());
609603
result
610604
}
605+
606+
unsafe fn from_arg_ptr(ptr: sys::GDExtensionTypePtr, _call_type: sys::PtrcallType) -> Self {
607+
let array = Self::from_sys(ptr);
608+
std::mem::forget(array.share());
609+
array
610+
}
611611
}
612612

613613
impl<T: VariantMetadata> fmt::Debug for Array<T> {

godot-core/src/builtin/basis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ unsafe impl GodotFfi for Basis {
579579

580580
/// The ordering used to interpret a set of euler angles as extrinsic
581581
/// rotations.
582-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
582+
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
583583
#[repr(C)]
584584
pub enum EulerOrder {
585585
XYZ = 0,

godot-core/src/builtin/color.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ use sys::{ffi_methods, GodotFfi};
1515
/// Channel values are _typically_ in the range of 0 to 1, but this is not a requirement, and
1616
/// values outside this range are explicitly allowed for e.g. High Dynamic Range (HDR).
1717
#[repr(C)]
18-
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
18+
#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)]
1919
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2020
pub struct Color {
2121
/// The color's red component.
2222
pub r: f32,
23+
2324
/// The color's green component.
2425
pub g: f32,
26+
2527
/// The color's blue component.
2628
pub b: f32,
29+
2730
/// The color's alpha component. A value of 0 means that the color is fully transparent. A
2831
/// value of 1 means that the color is fully opaque.
2932
pub a: f32,
@@ -318,12 +321,14 @@ unsafe impl GodotFfi for Color {
318321
ffi_methods! { type sys::GDExtensionTypePtr = *mut Self; .. }
319322
}
320323

321-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
324+
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
322325
pub enum ColorChannelOrder {
323326
/// RGBA channel order. Godot's default.
324327
Rgba,
328+
325329
/// ABGR channel order. Reverse of the default RGBA order.
326330
Abgr,
331+
327332
/// ARGB channel order. More compatible with DirectX.
328333
Argb,
329334
}

godot-core/src/builtin/dictionary.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,17 @@ unsafe impl GodotFfi for Dictionary {
262262
fn move_return_ptr;
263263
}
264264

265-
unsafe fn from_arg_ptr(ptr: sys::GDExtensionTypePtr, _call_type: sys::PtrcallType) -> Self {
266-
let dictionary = Self::from_sys(ptr);
267-
std::mem::forget(dictionary.share());
268-
dictionary
269-
}
270-
271265
unsafe fn from_sys_init_default(init_fn: impl FnOnce(sys::GDExtensionTypePtr)) -> Self {
272266
let mut result = Self::default();
273267
init_fn(result.sys_mut());
274268
result
275269
}
270+
271+
unsafe fn from_arg_ptr(ptr: sys::GDExtensionTypePtr, _call_type: sys::PtrcallType) -> Self {
272+
let dictionary = Self::from_sys(ptr);
273+
std::mem::forget(dictionary.share());
274+
dictionary
275+
}
276276
}
277277

278278
impl_builtin_traits! {

godot-core/src/builtin/meta/class_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::obj::GodotClass;
1313

1414
/// Utility to construct class names known at compile time.
1515
/// Cannot be a function since the backing string must be retained.
16-
#[derive(Eq, PartialEq, Hash, Clone, Debug)]
16+
#[derive(Clone, Eq, PartialEq, Hash, Debug)]
1717
pub struct ClassName {
1818
backing: StringName,
1919
}

godot-core/src/builtin/projection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ unsafe impl GodotFfi for Projection {
494494
}
495495

496496
/// A projections clipping plane.
497-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
497+
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
498498
#[repr(C)]
499499
pub enum ProjectionPlane {
500500
Near = 0,
@@ -507,7 +507,7 @@ pub enum ProjectionPlane {
507507

508508
/// The eye to create a projection for, when creating a projection adjusted
509509
/// for head-mounted displays.
510-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
510+
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
511511
#[repr(C)]
512512
pub enum ProjectionEye {
513513
Left = 1,

godot-core/src/builtin/rect2i.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use super::{Rect2, RectSide, Vector2i};
2020
pub struct Rect2i {
2121
/// The position of the rectangle.
2222
pub position: Vector2i,
23+
2324
/// The size of the rectangle.
2425
pub size: Vector2i,
2526
}

godot-core/src/builtin/rid.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ use sys::{ffi_methods, GodotFfi};
3030
// eligible for it, it is also guaranteed to have it. Meaning the layout of this type is identical to `u64`.
3131
// See: https://doc.rust-lang.org/nomicon/ffi.html#the-nullable-pointer-optimization
3232
// Cannot use `#[repr(C)]` as it does not use the nullable pointer optimization.
33-
#[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd, Debug)]
33+
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
3434
pub enum Rid {
3535
/// A valid RID may refer to some resource, but is not guaranteed to do so.
3636
Valid(NonZeroU64),
37+
3738
/// An invalid RID will never refer to a resource. Internally it is represented as a 0.
3839
Invalid,
3940
}

godot-core/src/builtin/variant/mod.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,12 @@ impl Variant {
201201
}
202202

203203
/// Converts to variant pointer; can be a null pointer.
204-
pub(crate) fn ptr_from_sys(
205-
variant_ptr: sys::GDExtensionVariantPtr,
206-
) -> *const Variant {
204+
pub(crate) fn ptr_from_sys(variant_ptr: sys::GDExtensionVariantPtr) -> *const Variant {
207205
variant_ptr as *const Variant
208206
}
209207

210208
/// Converts to variant mut pointer; can be a null pointer.
211-
pub(crate) fn ptr_from_sys_mut(
212-
variant_ptr: sys::GDExtensionVariantPtr,
213-
) -> *mut Variant {
209+
pub(crate) fn ptr_from_sys_mut(variant_ptr: sys::GDExtensionVariantPtr) -> *mut Variant {
214210
variant_ptr as *mut Variant
215211
}
216212
}

godot-core/src/builtin/variant/variant_traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub trait ToVariant {
4949

5050
// ----------------------------------------------------------------------------------------------------------------------------------------------
5151

52-
#[derive(Debug, Eq, PartialEq)]
52+
#[derive(Eq, PartialEq, Debug)]
5353
pub struct VariantConversionError;
5454
/*pub enum VariantConversionError {
5555
/// Variant type does not match expected type

godot-core/src/builtin/vector2.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ use super::{real, RAffine2, RVec2};
2626
/// vectors; use the gdext library with the `double-precision` feature in that case.
2727
///
2828
/// See [`Vector2i`] for its integer counterpart.
29-
#[derive(Debug, Default, Clone, Copy, PartialEq)]
29+
#[derive(Default, Copy, Clone, PartialEq, Debug)]
3030
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3131
#[repr(C)]
3232
pub struct Vector2 {
3333
/// The vector's X component.
3434
pub x: real,
35+
3536
/// The vector's Y component.
3637
pub y: real,
3738
}
@@ -318,11 +319,12 @@ unsafe impl GodotFfi for Vector2 {
318319
}
319320

320321
/// Enumerates the axes in a [`Vector2`].
321-
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
322+
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
322323
#[repr(i32)]
323324
pub enum Vector2Axis {
324325
/// The X axis.
325326
X,
327+
326328
/// The Y axis.
327329
Y,
328330
}

godot-core/src/builtin/vector2i.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ use super::IVec2;
2323
/// required. Note that the values are limited to 32 bits, and unlike [`Vector2`] this cannot be
2424
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`] if 64-bit values are
2525
/// needed.
26-
#[derive(Debug, Default, Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
26+
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
2727
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2828
#[repr(C)]
2929
pub struct Vector2i {
3030
/// The vector's X component.
3131
pub x: i32,
32+
3233
/// The vector's Y component.
3334
pub y: i32,
3435
}
@@ -99,11 +100,12 @@ unsafe impl GodotFfi for Vector2i {
99100
}
100101

101102
/// Enumerates the axes in a [`Vector2i`].
102-
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
103+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
103104
#[repr(i32)]
104105
pub enum Vector2iAxis {
105106
/// The X axis.
106107
X,
108+
107109
/// The Y axis.
108110
Y,
109111
}

godot-core/src/builtin/vector3.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ use super::{real, Basis, RVec3};
2727
/// vectors; use the gdext library with the `double-precision` feature in that case.
2828
///
2929
/// See [`Vector3i`] for its integer counterpart.
30-
#[derive(Debug, Default, Clone, Copy, PartialEq)]
30+
#[derive(Default, Copy, Clone, PartialEq, Debug)]
3131
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3232
#[repr(C)]
3333
pub struct Vector3 {
3434
/// The vector's X component.
3535
pub x: real,
36+
3637
/// The vector's Y component.
3738
pub y: real,
39+
3840
/// The vector's Z component.
3941
pub z: real,
4042
}
@@ -338,13 +340,15 @@ unsafe impl GodotFfi for Vector3 {
338340

339341
/// Enumerates the axes in a [`Vector3`].
340342
// TODO auto-generate this, alongside all the other builtin type's enums
341-
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
343+
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
342344
#[repr(i32)]
343345
pub enum Vector3Axis {
344346
/// The X axis.
345347
X,
348+
346349
/// The Y axis.
347350
Y,
351+
348352
/// The Z axis.
349353
Z,
350354
}

godot-core/src/builtin/vector3i.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ use super::IVec3;
2323
/// required. Note that the values are limited to 32 bits, and unlike [`Vector3`] this cannot be
2424
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`] if 64-bit values are
2525
/// needed.
26-
#[derive(Debug, Default, Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
26+
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
2727
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2828
#[repr(C)]
2929
pub struct Vector3i {
3030
/// The vector's X component.
3131
pub x: i32,
32+
3233
/// The vector's Y component.
3334
pub y: i32,
35+
3436
/// The vector's Z component.
3537
pub z: i32,
3638
}
@@ -113,8 +115,10 @@ unsafe impl GodotFfi for Vector3i {
113115
pub enum Vector3iAxis {
114116
/// The X axis.
115117
X,
118+
116119
/// The Y axis.
117120
Y,
121+
118122
/// The Z axis.
119123
Z,
120124
}

godot-core/src/builtin/vector4.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ use super::{real, RVec4};
2424
/// vectors; use the gdext library with the `double-precision` feature in that case.
2525
///
2626
/// See [`Vector4i`] for its integer counterpart.
27-
#[derive(Debug, Default, Clone, Copy, PartialEq)]
27+
#[derive(Default, Copy, Clone, PartialEq, Debug)]
2828
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2929
#[repr(C)]
3030
pub struct Vector4 {
3131
/// The vector's X component.
3232
pub x: real,
33+
3334
/// The vector's Y component.
3435
pub y: real,
36+
3537
/// The vector's Z component.
3638
pub z: real,
39+
3740
/// The vector's W component.
3841
pub w: real,
3942
}
@@ -105,15 +108,18 @@ unsafe impl GodotFfi for Vector4 {
105108
}
106109

107110
/// Enumerates the axes in a [`Vector4`].
108-
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
111+
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
109112
#[repr(i32)]
110113
pub enum Vector4Axis {
111114
/// The X axis.
112115
X,
116+
113117
/// The Y axis.
114118
Y,
119+
115120
/// The Z axis.
116121
Z,
122+
117123
/// The W axis.
118124
W,
119125
}

godot-core/src/builtin/vector4i.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@ use super::IVec4;
2222
/// required. Note that the values are limited to 32 bits, and unlike [`Vector4`] this cannot be
2323
/// configured with an engine build option. Use `i64` or [`PackedInt64Array`] if 64-bit values are
2424
/// needed.
25-
#[derive(Debug, Default, Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
25+
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
2626
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2727
#[repr(C)]
2828
pub struct Vector4i {
2929
/// The vector's X component.
3030
pub x: i32,
31+
3132
/// The vector's Y component.
3233
pub y: i32,
34+
3335
/// The vector's Z component.
3436
pub z: i32,
37+
3538
/// The vector's W component.
3639
pub w: i32,
3740
}
@@ -93,15 +96,18 @@ unsafe impl GodotFfi for Vector4i {
9396
}
9497

9598
/// Enumerates the axes in a [`Vector4i`].
96-
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
99+
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
97100
#[repr(i32)]
98101
pub enum Vector4iAxis {
99102
/// The X axis.
100103
X,
104+
101105
/// The Y axis.
102106
Y,
107+
103108
/// The Z axis.
104109
Z,
110+
105111
/// The W axis.
106112
W,
107113
}

godot-core/src/obj/instance_id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::num::NonZeroU64;
1515
///
1616
/// This is its own type for type safety and to deal with the inconsistent representation in Godot as both `u64` (C++) and `i64` (GDScript).
1717
/// You can usually treat this as an opaque value and pass it to and from GDScript; there are conversion methods however.
18-
#[derive(Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
18+
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1919
#[repr(transparent)]
2020
pub struct InstanceId {
2121
// Note: in the public API, signed i64 is the canonical representation.

godot-core/src/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Debug for ErasedRegisterFn {
4444
}
4545

4646
/// Represents the data part of a [`ClassPlugin`] instance.
47-
#[derive(Debug, Clone)]
47+
#[derive(Clone, Debug)]
4848
pub enum PluginComponent {
4949
/// Class definition itself, must always be available
5050
ClassDef {

godot-ffi/src/godot_ffi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub enum PtrcallType {
103103
/// return value must be moved into the return pointer.
104104
#[default]
105105
Standard,
106+
106107
/// Virtual pointer call.
107108
///
108109
/// A virtual call behaves like [`PtrcallType::Standard`], except for `RefCounted` objects.

0 commit comments

Comments
 (0)