Skip to content

Commit 66682cb

Browse files
Set edition and fix clippy lints (#21)
* add edition * clone fixes * crate prefixes * redundant named args * non anonymous args
1 parent c901cc6 commit 66682cb

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "pscontroller-rs"
33
version = "0.7.0"
44
authors = ["Edwin Amsler"]
5+
edition = "2018"
56

67
categories = ["embedded", "hardware-support", "no-std"]
78
description = "A hardware-level platform agnostic driver for PlayStation 1 or 2 contoller peripherals. Requires soldering. 😁"

src/classic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,6 @@ pub struct Classic {
134134

135135
impl HasStandardButtons for Classic {
136136
fn buttons(&self) -> GamepadButtons {
137-
self.buttons.clone()
137+
self.buttons
138138
}
139139
}

src/dualshock.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! This also maps for the the Dual Analog (precursor to the Dual Shock) and
77
//! the Analog controller (flight stick) as they both have the same buttons
88
9-
use classic::GamepadButtons;
9+
use crate::classic::GamepadButtons;
1010
use super::{
1111
HasStandardButtons,
1212
PollCommand
@@ -31,7 +31,7 @@ pub struct DualShock {
3131

3232
impl HasStandardButtons for DualShock {
3333
fn buttons(&self) -> GamepadButtons {
34-
self.buttons.clone()
34+
self.buttons
3535
}
3636
}
3737

@@ -58,7 +58,7 @@ pub struct DualShock2 {
5858

5959
impl HasStandardButtons for DualShock2 {
6060
fn buttons(&self) -> GamepadButtons {
61-
self.buttons.clone()
61+
self.buttons
6262
}
6363
}
6464

@@ -75,8 +75,8 @@ impl ControlDS {
7575
/// Create a new one of thes newfangled control commands
7676
pub fn new(little: bool, big: u8) -> Self {
7777
Self {
78-
little: little,
79-
big: big,
78+
little,
79+
big,
8080
}
8181
}
8282
}

src/guitarhero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ pub struct GuitarHero {
9595
impl GuitarHero {
9696
/// Get a copy of the buttons that were pressed
9797
pub fn buttons(&self) -> GuitarButtons {
98-
self.buttons.clone()
98+
self.buttons
9999
}
100100
}

src/jogcon.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! but it is featureful enough that it can be treated as a servo motor with
66
//! little effort.
77
8-
use classic::GamepadButtons;
8+
use crate::classic::GamepadButtons;
99
use byteorder::{
1010
ByteOrder,
1111
LittleEndian
@@ -73,7 +73,7 @@ impl JogCon {
7373

7474
impl HasStandardButtons for JogCon {
7575
fn buttons(&self) -> GamepadButtons {
76-
self.buttons.clone()
76+
self.buttons
7777
}
7878
}
7979

@@ -89,8 +89,8 @@ impl ControlJC {
8989
/// Create a new one of thes newfangled control commands
9090
pub fn new(mode: JogControl, strength: u8) -> Self {
9191
Self {
92-
mode: mode,
93-
strength: strength,
92+
mode,
93+
strength,
9494
}
9595
}
9696
}

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub trait PollCommand {
204204
/// Re-write the provided slice starting from index 0. This command
205205
/// is called by read_input() which will provide a sub-slice of the
206206
/// controller's command bytes.
207-
fn set_command(&self, &mut [u8]);
207+
fn set_command(&self, _: &mut [u8]);
208208
}
209209

210210
/// Many controllers have the same set of buttons (Square, Circle, L3, R1, etc).
@@ -416,7 +416,7 @@ where
416416
Ok(config)
417417
}
418418

419-
fn read_port(&mut self, command: Option<&PollCommand>) -> Result<[u8; MESSAGE_MAX_LENGTH], Error<E>> {
419+
fn read_port(&mut self, command: Option<&dyn PollCommand>) -> Result<[u8; MESSAGE_MAX_LENGTH], Error<E>> {
420420
let mut buffer = [0u8; MESSAGE_MAX_LENGTH];
421421
let mut data = [0u8; MESSAGE_MAX_LENGTH];
422422

@@ -448,7 +448,7 @@ where
448448
/// Get the raw data from polling for a controller. You can use this to cooerce the data into
449449
/// some controller that can't be safely identified by `read_input`, but you should rely on that
450450
/// function if you can.
451-
pub fn read_raw(&mut self, command: Option<&PollCommand>) -> Result<ControllerData, Error<E>> {
451+
pub fn read_raw(&mut self, command: Option<&dyn PollCommand>) -> Result<ControllerData, Error<E>> {
452452
let mut buffer = [0u8; MESSAGE_MAX_LENGTH];
453453
let data = self.read_port(command)?;
454454

@@ -463,7 +463,7 @@ where
463463

464464
/// Ask the controller for input states. Different contoller types will be returned automatically
465465
/// for you. If you'd like to cooerce a controller yourself, use `read_raw`.
466-
pub fn read_input(&mut self, command: Option<&PollCommand>) -> Result<Device, Error<E>> {
466+
pub fn read_input(&mut self, command: Option<&dyn PollCommand>) -> Result<Device, Error<E>> {
467467
let mut buffer = [0u8; MESSAGE_MAX_LENGTH];
468468
let data = self.read_port(command)?;
469469

0 commit comments

Comments
 (0)