Skip to content

Commit

Permalink
Remove a bunch of un-needed clones
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed May 31, 2024
1 parent 78f77a7 commit ec5fa39
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ pub fn run_core() -> Subscription<Message> {
// Setup UI Handle
let (ui_handle, mut core_handle) = bridge::create_handles();
let arc_ui_handle = Arc::new(ui_handle);
tx.send(Message::UIHandlerLoaded(arc_ui_handle.clone()))
tx.send(Message::UIHandlerLoaded(arc_ui_handle))
.await
.expect("should send");

Expand Down
4 changes: 2 additions & 2 deletions src/db_models/fedimint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ impl Fedimint {

pub fn update(&self, conn: &mut SqliteConnection) -> anyhow::Result<()> {
let _ = diesel::update(fedimint::table)
.filter(fedimint::id.eq(self.id.clone()))
.set(fedimint::value.eq(self.value.clone()))
.filter(fedimint::id.eq(&self.id))
.set(fedimint::value.eq(&self.value))
.execute(conn)?;

Ok(())
Expand Down
19 changes: 8 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl HarborWallet {
invoice: Bolt11Invoice,
) {
if let Some(ui_handle) = ui_handle {
ui_handle.clone().send_lightning(id, invoice).await;
ui_handle.send_lightning(id, invoice).await;
} else {
panic!("UI handle is None");
}
Expand All @@ -186,34 +186,31 @@ impl HarborWallet {
) {
println!("Got to async_send");
if let Some(ui_handle) = ui_handle {
ui_handle
.clone()
.send_onchain(id, address, amount_sats)
.await;
ui_handle.send_onchain(id, address, amount_sats).await;
} else {
panic!("UI handle is None");
}
}

async fn async_receive(ui_handle: Option<Arc<bridge::UIHandle>>, id: Uuid, amount: u64) {
if let Some(ui_handle) = ui_handle {
ui_handle.clone().receive(id, amount).await;
ui_handle.receive(id, amount).await;
} else {
panic!("UI handle is None");
}
}

async fn async_receive_onchain(ui_handle: Option<Arc<bridge::UIHandle>>, id: Uuid) {
if let Some(ui_handle) = ui_handle {
ui_handle.clone().receive_onchain(id).await;
ui_handle.receive_onchain(id).await;
} else {
panic!("UI handle is None");
}
}

async fn async_unlock(ui_handle: Option<Arc<bridge::UIHandle>>, id: Uuid, password: String) {
if let Some(ui_handle) = ui_handle {
ui_handle.clone().unlock(id, password).await;
ui_handle.unlock(id, password).await;
} else {
panic!("UI handle is None");
}
Expand All @@ -225,7 +222,7 @@ impl HarborWallet {
invite: InviteCode,
) {
if let Some(ui_handle) = ui_handle {
ui_handle.clone().add_federation(id, invite).await;
ui_handle.add_federation(id, invite).await;
} else {
panic!("UI handle is None");
}
Expand All @@ -237,15 +234,15 @@ impl HarborWallet {
invite: InviteCode,
) {
if let Some(ui_handle) = ui_handle {
ui_handle.clone().peek_federation(id, invite).await;
ui_handle.peek_federation(id, invite).await;
} else {
panic!("UI handle is None");
}
}

async fn async_get_seed_words(ui_handle: Option<Arc<bridge::UIHandle>>, id: Uuid) {
if let Some(ui_handle) = ui_handle {
ui_handle.clone().get_seed_words(id).await;
ui_handle.get_seed_words(id).await;
} else {
panic!("UI handle is None");
}
Expand Down

0 comments on commit ec5fa39

Please sign in to comment.