Skip to content

Commit b839fc9

Browse files
bors[bot]toasteater
andauthored
Merge #738
738: Fixing a bunch of new and future clippy lints r=toasteater a=toasteater Co-authored-by: toasteater <48371905+toasteater@users.noreply.github.com>
2 parents 86d7f95 + ac5f424 commit b839fc9

File tree

6 files changed

+21
-31
lines changed

6 files changed

+21
-31
lines changed

bindings_generator/src/dependency.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,14 @@ fn visit(api: &Api, class: &GodotClass, visited: &mut HashSet<String>) {
4545
fn base_classes(api: &Api, class: &GodotClass) -> HashSet<String> {
4646
let mut bases = HashSet::new();
4747

48-
if class.base_class.is_empty() {
49-
bases
50-
} else {
48+
if !class.base_class.is_empty() {
5149
if let Some(class) = api.find_class(&class.base_class) {
5250
bases.insert(class.name.clone());
53-
5451
bases.extend(base_classes(api, class));
5552
}
56-
bases
5753
}
54+
55+
bases
5856
}
5957

6058
fn referenced_classes(api: &Api, class: &GodotClass) -> HashSet<String> {

gdnative-core/src/core_types/color.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl Color {
110110
}
111111

112112
#[inline]
113-
pub fn to_html(&self, with_alpha: bool) -> GodotString {
113+
pub fn to_html(self, with_alpha: bool) -> GodotString {
114114
GodotString::from_sys(unsafe { (get_api().godot_color_to_html)(self.sys(), with_alpha) })
115115
}
116116

@@ -122,7 +122,7 @@ impl Color {
122122
/// # Example
123123
/// `0x00FF7FFF` would be the equivalent to `Color::from_rgba(1.0, 0.5, 1.0, 0.0)`
124124
#[inline]
125-
pub fn to_abgr32(&self) -> u32 {
125+
pub fn to_abgr32(self) -> u32 {
126126
((self.a * 255.0) as u32) << 24
127127
| ((self.b * 255.0) as u32) << 16
128128
| ((self.g * 255.0) as u32) << 8
@@ -137,7 +137,7 @@ impl Color {
137137
/// # Example
138138
/// `0x0000FFFF7FFFFFFF` would be the equivalent to `Color::from_rgba(0.0, 1.0, 0.5, 1.0)`
139139
#[inline]
140-
pub fn to_abgr64(&self) -> u64 {
140+
pub fn to_abgr64(self) -> u64 {
141141
((self.a * 65535.0) as u64) << 48
142142
| ((self.b * 65535.0) as u64) << 32
143143
| ((self.g * 65535.0) as u64) << 16
@@ -151,7 +151,7 @@ impl Color {
151151
/// On little endian machines this is stored in the order BGRA byte order
152152
/// `0x0000FFFF7FFFFFFF` would be the equivalent to `Color::from_rgba(1.0, 0.5, 1.0, 0.0)`
153153
#[inline]
154-
pub fn to_argb32(&self) -> u32 {
154+
pub fn to_argb32(self) -> u32 {
155155
((self.a * 255.0) as u32) << 24
156156
| ((self.r * 255.0) as u32) << 16
157157
| ((self.g * 255.0) as u32) << 8
@@ -166,7 +166,7 @@ impl Color {
166166
/// # Example
167167
/// `0x0000FFFF7FFFFFFF` would be the equivalent to `Color::from_rgba(1.0, 0.5, 1.0, 0.0)`
168168
#[inline]
169-
pub fn to_argb64(&self) -> u64 {
169+
pub fn to_argb64(self) -> u64 {
170170
((self.a * 65535.0) as u64) << 48
171171
| ((self.r * 65535.0) as u64) << 32
172172
| ((self.g * 65535.0) as u64) << 16
@@ -181,7 +181,7 @@ impl Color {
181181
/// # Example
182182
/// `0x00FF7FFF` would be the equivalent to `Color::from_rgba(0.0, 1.0, 0.5, 1.0)`
183183
#[inline]
184-
pub fn to_rgba32(&self) -> u32 {
184+
pub fn to_rgba32(self) -> u32 {
185185
((self.r * 255.0) as u32) << 24
186186
| ((self.g * 255.0) as u32) << 16
187187
| ((self.b * 255.0) as u32) << 8
@@ -196,7 +196,7 @@ impl Color {
196196
/// # Example
197197
/// `0x0000FFFF7FFFFFFF` would be the equivalent to `Color::from_rgba(0.0, 1.0, 0.5, 1.0)`
198198
#[inline]
199-
pub fn to_rgba64(&self) -> u64 {
199+
pub fn to_rgba64(self) -> u64 {
200200
((self.r * 65535.0) as u64) << 48
201201
| ((self.g * 65535.0) as u64) << 32
202202
| ((self.b * 65535.0) as u64) << 16

gdnative-core/src/core_types/geom/basis.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl Basis {
286286
///
287287
/// If `self` is not normalized.
288288
#[inline]
289-
pub fn to_quat(&self) -> Quat {
289+
pub fn to_quat(self) -> Quat {
290290
// Assumes that the matrix can be decomposed into a proper rotation and scaling matrix as M = R.S,
291291
// and returns the Euler angles corresponding to the rotation part, complementing get_scale().
292292
// See the comment in get_scale() for further information.
@@ -348,7 +348,7 @@ impl Basis {
348348

349349
/// Returns the scale of the matrix.
350350
#[inline]
351-
pub fn to_scale(&self) -> Vector3 {
351+
pub fn to_scale(self) -> Vector3 {
352352
let det = self.determinant();
353353
let det_sign = if det < 0.0 { -1.0 } else { 1.0 };
354354
Vector3::new(
@@ -383,7 +383,7 @@ impl Basis {
383383
///
384384
/// See [`Basis::to_quat`](#method.to_quat) if you need a quaternion instead.
385385
#[inline]
386-
pub fn to_euler(&self) -> Vector3 {
386+
pub fn to_euler(self) -> Vector3 {
387387
let mut euler = Vector3::ZERO;
388388

389389
let m12 = self.elements[1].z;

gdnative-core/src/core_types/string.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,9 @@ godot_test!(test_string {
636636
let cmp1: GodotString = "foo".into();
637637
let cmp2: GodotString = "foo".into();
638638
let cmp3: GodotString = "bar".into();
639-
assert_eq!(cmp1 < cmp2, false, "equal should not be less than");
640-
assert_eq!(cmp1 > cmp2, false, "equal should not be greater than");
641-
assert_eq!(cmp1 < cmp3, false, "foo should be less than bar");
642-
assert_eq!(cmp3 > cmp1, false, "bar should be greater than foo");
639+
assert_eq!(cmp1.cmp(&cmp2), Ordering::Equal, "equal should not be less than");
640+
assert_eq!(cmp1.cmp(&cmp3), Ordering::Greater, "foo should greater than bar");
641+
assert_eq!(cmp3.cmp(&cmp1), Ordering::Less, "bar should be less than foo");
643642

644643
let index_string: GodotString = "bar".into();
645644
assert_eq!(index_string[0], 'b');

gdnative-core/src/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ impl InitializeInfo {
6060
crate::core_types::GodotString::clone_from_sys(*active_library_path);
6161

6262
Self {
63-
options,
6463
in_editor,
6564
active_library_path,
65+
options,
6666
}
6767
}
6868

gdnative-derive/src/native_script.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,10 @@ pub(crate) fn derive_native_class(derive_input: &DeriveInput) -> Result<TokenStr
5151
.map(|function_path| quote!(#function_path(builder);))
5252
.unwrap_or(quote!({}));
5353
let properties = data.properties.into_iter().map(|(ident, config)| {
54-
let with_default = if let Some(default_value) = &config.default {
55-
Some(quote!(.with_default(#default_value)))
56-
} else {
57-
None
58-
};
59-
60-
let with_hint = if let Some(hint_fn) = &config.hint {
61-
Some(quote!(.with_hint(#hint_fn())))
62-
} else {
63-
None
64-
};
54+
let with_default = config
55+
.default
56+
.map(|default_value| quote!(.with_default(#default_value)));
57+
let with_hint = config.hint.map(|hint_fn| quote!(.with_hint(#hint_fn())));
6558

6659
let with_usage = if config.no_editor {
6760
Some(quote!(.with_usage(::gdnative::nativescript::init::property::Usage::NOEDITOR)))

0 commit comments

Comments
 (0)