Integer values are limited by 2^63-1 (9223372036854775807).
Greetings!
Is there is a bug what integers are limited by 2^63-1?
use config::{Config, Environment, File, FileFormat};
fn main() {
// Ok
println!(
"number: `{}`.",
read_conf().get::<u64>("data.number").unwrap()
);
// Ok
std::env::set_var("PREFIX_data.number", (1u64 << 63 - 1).to_string());
println!(
"number: `{}`.",
read_conf().get::<u64>("data.number").unwrap()
);
// Error
std::env::set_var("PREFIX_data.number", (1u64 << 63).to_string());
println!(
"number: `{}`.",
read_conf().get::<u64>("data.number").unwrap_err()
);
}
#[inline]
fn read_conf() -> Config {
Config::builder()
.add_source(File::from_str("[data]\nnumber = 1024", FileFormat::Toml))
.add_source(Environment::with_prefix("PREFIX"))
.build()
.unwrap()
}
Hi, thanks for opening this issue!
Could you add a testcase for this?
In https://github.com/mehcode/config-rs/pull/178/ we added support for u128 if I see that correctly, so maybe you just need to check for u128? I am also not 100% sure whether all formats support intergers of this size...
In any case, a testcase would be phenomenal! :+1:
Greetings!
Sorry for such long answer. Too much shit in the world happens lately.
Could you add a testcase for this? You mean for this case? I tried to look up in tests, but put that in back burner. If I get some free time, will happy to do that.