aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2018-09-01 18:03:29 +0200
committerTeddy Wing2018-09-01 18:03:29 +0200
commit1cd5cd92b338d75f292d95fa031828cd9defa6e5 (patch)
tree519c00516cbe2cbfd868362600abac5b5eef438e /src
parenta432dd2824499959635ac9a7cabec25a31dddb14 (diff)
downloaddome-key-map-1cd5cd92b338d75f292d95fa031828cd9defa6e5.tar.bz2
KeyActionResult: Fix reference/borrow errors
Return struct values instead of references in the `KeyActionResult` impl to clear up the borrow errors from a432dd2824499959635ac9a7cabec25a31dddb14. Clean up some of the code. Remove the `build()` method because we no longer need it. The rest of the methods will already return the `KeyActionResult` we need.
Diffstat (limited to 'src')
-rw-r--r--src/cocoa_bridge.rs22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/cocoa_bridge.rs b/src/cocoa_bridge.rs
index 22fcc58..541abe7 100644
--- a/src/cocoa_bridge.rs
+++ b/src/cocoa_bridge.rs
@@ -64,20 +64,16 @@ impl<'a> KeyActionResult<'a> {
}
}
- fn with_action(&mut self, action: &str) -> &Self {
+ fn with_action(mut self, action: &str) -> Self {
let action = CString::new(action.clone()).unwrap();
self.action = Some(action);
self
}
- fn in_mode(&mut self, mode: &'a [HeadphoneButton]) -> &Self {
+ fn in_mode(mut self, mode: &'a [HeadphoneButton]) -> Self {
self.in_mode = Some(mode);
self
}
-
- fn build(&self) -> Self {
- *self
- }
}
#[repr(C)]
@@ -159,14 +155,14 @@ map <play><down> works!
return match map.kind {
MapKind::Map => {
Some(
- *KeyActionResult::new(MapKind::Map)
+ KeyActionResult::new(MapKind::Map)
.with_action(&map.action)
.in_mode(trigger)
)
},
MapKind::Command => {
Some(
- *KeyActionResult::new(MapKind::Command)
+ KeyActionResult::new(MapKind::Command)
.in_mode(trigger)
)
},
@@ -186,22 +182,12 @@ map <play><down> works!
Some(
KeyActionResult::new(MapKind::Map)
.with_action(&map.action)
- .build()
)
- // Some(KeyActionResult {
- // action: Some(action),
- // kind: MapKind::Map,
- // })
},
MapKind::Command => {
Some(
KeyActionResult::new(MapKind::Command)
- .build()
)
- // Some(KeyActionResult {
- // action: None,
- // kind: MapKind::Command,
- // })
},
}
}