Skip to content

Remove unnecessary clone #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl MyApp {
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
if let Ok(read_guard) = self.connected_lock.read() {
self.ready = read_guard.clone();
self.ready = *read_guard;
}
let right_panel_width = 350.0;

Expand Down Expand Up @@ -358,7 +358,7 @@ impl eframe::App for MyApp {
for baud_rate in baud_rates.iter() {
ui.selectable_value(
&mut self.baud_rate,
baud_rate.clone(),
*baud_rate,
format!("{}", baud_rate),
);
}
Expand All @@ -382,7 +382,7 @@ impl eframe::App for MyApp {
if self.ready {
// do nothing
} else {
*write_guard = self.baud_rate.clone();
*write_guard = self.baud_rate;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn main() {

let device_lock = Arc::new(RwLock::new(gui_settings.device.clone()));
let devices_lock = Arc::new(RwLock::new(vec![gui_settings.device.clone()]));
let baud_lock = Arc::new(RwLock::new(gui_settings.baud.clone()));
let baud_lock = Arc::new(RwLock::new(gui_settings.baud));
let raw_data_lock = Arc::new(RwLock::new(vec![Packet::default()]));
let data_lock = Arc::new(RwLock::new(DataContainer::default()));
let print_lock = Arc::new(RwLock::new(vec![Print::EMPTY]));
Expand Down
8 changes: 4 additions & 4 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ pub fn serial_thread(gui_settings: GuiSettingsContainer,

connected = false;
if let Ok(mut write_guard) = connected_lock.write() {
*write_guard = connected.clone();
*write_guard = connected;
}

while !connected {
if let Ok(read_guard) = baud_lock.read() {
baud_rate = read_guard.clone()
baud_rate = *read_guard
}
if let Ok(read_guard) = device_lock.read() {
device = read_guard.clone();
Expand Down Expand Up @@ -100,7 +100,7 @@ pub fn serial_thread(gui_settings: GuiSettingsContainer,
let mut port = BufReader::new(port);

if let Ok(mut write_guard) = connected_lock.write() {
*write_guard = connected.clone();
*write_guard = connected;
}

let t_zero = Instant::now();
Expand Down Expand Up @@ -130,7 +130,7 @@ pub fn serial_thread(gui_settings: GuiSettingsContainer,

if let Ok(read_guard) = baud_lock.read() {
if baud_rate != *read_guard {
baud_rate = read_guard.clone();
baud_rate = *read_guard;
reconnect = true;
}
}
Expand Down