MCPcopy Create free account
hub / github.com/derekbanas/Rust-Tutorial / withdraw

Function withdraw

main.rs:1059–1070  ·  view source on GitHub ↗
(the_bank: &Arc<Mutex<Bank>>, amt:f32)

Source from the content-addressed store, hash-verified

1057 use std::sync::{Arc, Mutex};
1058
1059 fn withdraw(the_bank: &Arc<Mutex<Bank>>, amt:f32){
1060 let mut bank_ref = the_bank.lock().unwrap();
1061
1062 if bank_ref.balance < 5.00{
1063 println!("Current Balance : {} Withdrawal a smaller amount",
1064 bank_ref.balance);
1065 } else {
1066 bank_ref.balance -= amt;
1067 println!("Customer withdrew {} Current Balance {}",
1068 amt, bank_ref.balance);
1069 }
1070 }
1071
1072 fn customer(the_bank: Arc<Mutex<Bank>>) {
1073 withdraw(&the_bank, 5.00);

Callers 1

customerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected