Closed moaz-mokhtar closed 3 years ago
hey @moaz-mokhtar - thanks for reporting. Could you share a snippet of the code which panics?
Panicked as below:
lib_debtsolver on master [?] is 📦 v0.1.0 via 🦀 v1.50.0
❯ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/lib_debtsolver`
thread 'main' panicked at 'explicit panic', /home/moaz_mokhtar/.cargo/registry/src/github.com-1ecc6299db9ec823/rusty-money-0.1.0/src/lib.rs:62:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
lib_debtsolver on master [?] is 📦 v0.1.0 via 🦀 v1.50.0
❯ RUST_BACKTRACE=1 cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.09s
Running `target/debug/lib_debtsolver`
thread 'main' panicked at 'explicit panic', /home/moaz_mokhtar/.cargo/registry/src/github.com-1ecc6299db9ec823/rusty-money-0.1.0/src/lib.rs:62:18
stack backtrace:
0: std::panicking::begin_panic
at /home/moaz_mokhtar/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:519:12
1: rusty_money::Currency::new
at /home/moaz_mokhtar/.cargo/registry/src/github.com-1ecc6299db9ec823/rusty-money-0.1.0/src/lib.rs:62:18
2: rusty_money::Money::from_string
at /home/moaz_mokhtar/.cargo/registry/src/github.com-1ecc6299db9ec823/rusty-money-0.1.0/src/lib.rs:172:29
3: debtsolver::Transaction::from_tuple
at /home/moaz_mokhtar/.cargo/registry/src/github.com-1ecc6299db9ec823/debtsolver-0.2.0/src/lib.rs:123:28
4: lib_debtsolver::lab_example
at ./src/main.rs:55:32
5: lib_debtsolver::main
at ./src/main.rs:9:5
6: core::ops::function::FnOnce::call_once
at /home/moaz_mokhtar/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Also note that file rusty_money/src/currency.rs
shows only 2 currencies (real and fake) supported as below:
#[cfg(test)]
mod tests {
define_currency_set!(
real {
USD: {
code: "USD",
exponent: 2,
locale: EnUs,
minor_units: 100,
name: "USD",
symbol: "$",
symbol_first: true,
}
},
magic {
FOO: {
code: "FOO",
exponent: 3,
locale: EnUs,
minor_units: 100,
name: "FOO",
symbol: "F",
symbol_first: true,
}
}
);
thanks for the trace @moaz-mokhtar - could you share the actual code that causes this error?
the part in rusty_money/src/currency.rs
is just the test suite and this is expected. the full list of currencies is only enabled when you turn on the iso and crypto features. the tests are designed to work without enabling any of the features so they just defined some dummy currencies and make sure that the basic features work
I didn't use the rusty_money
directly, but it have been invoked by debtsolver
which I was testing. I did use Egypt Currency LE as below code.
extern crate debtsolver;
use debtsolver::transaction;
use debtsolver::Ledger;
use debtsolver::Transaction;
fn main() {
// main_example();
lab_example();
}
fn lab_example() {
let mut lab_ledger = Ledger::new();
// println!("{:?}", lab_ledger);
// let patient = "Ahmed Said";
// let receptionist = "Ayman Ali";
// let invoice = (140, "USD");
// println!("\t{:?}\n\t{:?}\n\t{:?}", patient, receptionist, invoice);
lab_ledger.add_transaction(transaction!("patient 1", "receptionist 1", (130, "LE")));
lab_ledger.add_transaction(transaction!("patient 2", "receptionist 1", (430, "LE")));
lab_ledger.add_transaction(transaction!("patient 3", "receptionist 1", (40, "LE")));
println!("Laboratory Ledger: {:#?}", lab_ledger);
// let trans = transaction!(patient, receptionist, invoice);
// let trans = transaction!("patient", "receptionist", (132, "USD"));
// println!("{:?}", trans);
// lab_ledger.add_transaction(trans);
// println!("{:?}", lab_ledger);
for trans in lab_ledger.settle() {
println!("TRANSACTION: {} :: {:#?}", trans, trans)
}
}
I believe the ISO symbol should be EGP
not LE
.
The panic is probably an issue in the debtsolver library, closing this for now,
I did use "EGP" but same issue.
One of the reasons which I'm expecting is that debtsolver
based in his Cargo.toml
on older version for rusty_money
. I will test using last version and will see.
debtsolver/Cargo.toml
[dependencies]
itertools = "0.8.2"
rusty-money = "0.3.0"
Very thankful @varunsrin for your respond.
Greetings to all,
Need to cover other currencies, which is not covered yet. For example I tried with Egyptian Pound but it pancis. Library should return a clear error message that this currency is not supported yet.