summary refs log tree commit diff
path: root/devices/src/usb
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-04-15 15:56:35 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-18 19:51:01 -0700
commit64cd5eae5778b86f6e498a6fa1b1962693aa5a46 (patch)
tree9b68f7fce3385c410f4fd9c4e978660a9b5a0973 /devices/src/usb
parentb1de6323ab8c96c52a60e0ff735e4bbb8a8464c9 (diff)
downloadcrosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.gz
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.bz2
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.lz
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.xz
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.zst
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.zip
edition: Eliminate ref keyword
As described in:
https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/default-match-bindings.html
which also covers the new mental model that the Rust Book will use for
teaching binding modes and has been found to be more friendly for both
beginners and experienced users.

Before:

    match *opt {
        Some(ref v) => ...,
        None => ...,
    }

After:

    match opt {
        Some(v) => ...,
        None => ...,
    }

TEST=cargo check --all-features
TEST=local kokoro

Change-Id: I3c5800a9be36aaf5d3290ae3bd3116f699cb00b7
Reviewed-on: https://chromium-review.googlesource.com/1566669
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'devices/src/usb')
-rw-r--r--devices/src/usb/host_backend/host_backend_device_provider.rs4
-rw-r--r--devices/src/usb/host_backend/host_device.rs2
-rw-r--r--devices/src/usb/xhci/device_slot.rs4
-rw-r--r--devices/src/usb/xhci/xhci_controller.rs6
4 files changed, 7 insertions, 9 deletions
diff --git a/devices/src/usb/host_backend/host_backend_device_provider.rs b/devices/src/usb/host_backend/host_backend_device_provider.rs
index beae028..6a68951 100644
--- a/devices/src/usb/host_backend/host_backend_device_provider.rs
+++ b/devices/src/usb/host_backend/host_backend_device_provider.rs
@@ -290,8 +290,8 @@ impl ProviderInner {
             UsbControlCommand::ListDevice { port } => {
                 let port_number = port;
                 let result = match self.usb_hub.get_port(port_number) {
-                    Some(port) => match *port.get_backend_device() {
-                        Some(ref device) => {
+                    Some(port) => match port.get_backend_device().as_ref() {
+                        Some(device) => {
                             let vid = device.get_vid();
                             let pid = device.get_pid();
                             UsbControlResult::Device {
diff --git a/devices/src/usb/host_backend/host_device.rs b/devices/src/usb/host_backend/host_device.rs
index cb4097e..b7ca0d1 100644
--- a/devices/src/usb/host_backend/host_device.rs
+++ b/devices/src/usb/host_backend/host_device.rs
@@ -299,7 +299,7 @@ impl HostDevice {
                                 }
                                 XhciTransferState::Completed => {
                                     let status = t.status();
-                                    if let Some(ref buffer) = buffer {
+                                    if let Some(buffer) = &buffer {
                                         let _bytes = buffer
                                             .write(&t.buffer().data_buffer)
                                             .map_err(Error::WriteBuffer)?
diff --git a/devices/src/usb/xhci/device_slot.rs b/devices/src/usb/xhci/device_slot.rs
index 5f82d4a..ef58edb 100644
--- a/devices/src/usb/xhci/device_slot.rs
+++ b/devices/src/usb/xhci/device_slot.rs
@@ -430,8 +430,8 @@ impl DeviceSlot {
                 .set_state(DeviceSlotState::Default);
         } else {
             let port = self.hub.get_port(port_id).ok_or(Error::GetPort(port_id))?;
-            match *port.get_backend_device() {
-                Some(ref mut backend) => {
+            match port.get_backend_device().as_mut() {
+                Some(backend) => {
                     backend.set_address(self.slot_id as u32);
                 }
                 None => {
diff --git a/devices/src/usb/xhci/xhci_controller.rs b/devices/src/usb/xhci/xhci_controller.rs
index 03f2cfc..1f58a5d 100644
--- a/devices/src/usb/xhci/xhci_controller.rs
+++ b/devices/src/usb/xhci/xhci_controller.rs
@@ -168,10 +168,8 @@ impl PciDevice for XhciController {
     }
 
     fn keep_fds(&self) -> Vec<RawFd> {
-        match self.state {
-            XhciControllerState::Created {
-                ref device_provider,
-            } => device_provider.keep_fds(),
+        match &self.state {
+            XhciControllerState::Created { device_provider } => device_provider.keep_fds(),
             _ => {
                 error!("xhci controller is in a wrong state");
                 vec![]