String formatting BigInt with num-format crate gives error

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 method to_formatted_string exists but the following trait bounds were not satisfied:
num_bigint::bigint::BigInt: num_format::to_formatted_str::ToFormattedStr
which is required by num_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));
}

num-format uses Num 0.2, but you're using Num 0.3, you'll have to downgrade to Num 0.2. You should make a PR to num-format if you want them to update, it'll probably be easy.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.