Hey,
I'm trying to print a BigInt to the console using the num_format
crate to allow multiple locales. But I'm getting the following error:
method not found in
num_bigint::bigint::BigInt
| pub struct BigInt {
| -----------------
| |
| doesn't satisfy_: num_format::to_formatted_str::ToFormattedStr
| doesn't satisfy_: num_format::to_formatted_string::ToFormattedString
|
= note: the methodto_formatted_string
exists but the following trait bounds were not satisfied:
num_bigint::bigint::BigInt: num_format::to_formatted_str::ToFormattedStr
which is required bynum_bigint::bigint::BigInt: num_format::to_formatted_string::ToFormattedString
From what I've read (even in the source of the crate) the implementation of ToFormattedString
for BigInt
does exist, why doesn't this work?
This is what I'm doing:
[dependencies]
num = "0.3.0"
num-format = { version = "0.4", features = ["with-num-bigint"] }
use num_format::{ Locale, ToFormattedString };
use num::bigint::BigInt;
fn main() {
let a = BigInt::from(10644);
let b = BigInt::from(-485);
let c = BigInt::from(334);
println!("{}", a.to_formatted_string(&Locale::en));
println!("{}", b.to_formatted_string(&Locale::pt));
println!("{}", c.to_formatted_string(&Locale::fr));
}