Skip to content

Commit

Permalink
Appease clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
chitoyuu committed Dec 7, 2022
1 parent 99ef5bb commit ffe6fc2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
msrv = "1.63.0"
4 changes: 2 additions & 2 deletions examples/dodge-the-creeps/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ impl Player {
let change = velocity * delta;
let position = owner.global_position() + change;
let position = Vector2::new(
position.x.max(0.0).min(self.screen_size.x),
position.y.max(0.0).min(self.screen_size.y),
position.x.clamp(0.0, self.screen_size.x),
position.y.clamp(0.0, self.screen_size.y),
);
owner.set_global_position(position);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/scene-create/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl SceneCreate {
Ok(spatial) => {
// Here is how you rename the child...
let key_str = format!("child_{}", self.children_spawned);
spatial.set_name(&key_str);
spatial.set_name(key_str);

let x = (self.children_spawned % 10) as f32;
let z = (self.children_spawned / 10) as f32;
Expand Down
8 changes: 7 additions & 1 deletion gdnative-core/src/core_types/geom/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ impl Transform {
This method will be renamed to translated_local in gdnative 0.12."]
#[inline]
pub fn translated(&self, translation: Vector3) -> Self {
self.translated_local(translation)
}

/// Returns this transform, with its origin moved by a certain `translation`
#[inline]
pub fn translated_local(&self, translation: Vector3) -> Self {
Self {
basis: self.basis,
origin: self.origin + translation,
Expand Down Expand Up @@ -365,7 +371,7 @@ mod tests {
#[test]
fn translation_is_sane() {
let translation = Vector3::new(1.0, 2.0, 3.0);
let t = Transform::default().translated(translation);
let t = Transform::default().translated_local(translation);
assert!(t.basis.elements[0] == Vector3::new(1.0, 0.0, 0.0));
assert!(t.basis.elements[1] == Vector3::new(0.0, 1.0, 0.0));
assert!(t.basis.elements[2] == Vector3::new(0.0, 0.0, 1.0));
Expand Down
5 changes: 4 additions & 1 deletion gdnative-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
clippy::missing_safety_doc,
clippy::non_send_fields_in_send_ty
)]
#![cfg_attr(feature = "gd-test", allow(clippy::blacklisted_name))]
#![cfg_attr(
any(test, feature = "gd-test"),
allow(clippy::excessive_precision, clippy::disallowed_names)
)]

#[doc(hidden)]
pub extern crate gdnative_sys as sys;
Expand Down
2 changes: 1 addition & 1 deletion test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::blacklisted_name)]
#![allow(clippy::disallowed_names)]
#![allow(deprecated)]

use gdnative::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion test/src/test_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) fn run_tests() -> bool {

thread_local! {
static EXECUTOR: &'static SharedLocalPool = {
Box::leak(Box::new(SharedLocalPool::default()))
Box::leak(Box::default())
};
}

Expand Down

0 comments on commit ffe6fc2

Please sign in to comment.