-
Notifications
You must be signed in to change notification settings - Fork 148
Closed
Labels
tracked-in-jiraTicket filed in Mongo's Jira systemTicket filed in Mongo's Jira system
Description
Versions/Environment
- What version of Rust are you using?
rustc 1.82.0-nightly (506052d49 2024-08-16)
- What operating system are you using?
Linux
- What versions of the driver and its dependencies are you using? (Run
cargo pkgid mongodb
&cargo pkgid bson
)
bson
:registry+https://github.com/rust-lang/crates.io-index#[email protected]
mongodb
: N/A
- What version of MongoDB are you using? (Check with the MongoDB shell using
db.version()
)
N/A - What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?
N/A
Describe the bug
A clear and concise description of what the bug is.
BE SPECIFIC:
- What is the expected behavior and what is actually happening?
Expected behaviour:
Bson
formatting outputs the following:
{
"key": "Hello world!"
}
What actually happens:
Bson
formatting outputs the following:
{ "key": "Hello world!" }
- Do you have any ideas on why this may be happening that could give us a
clue in the right direction?
If you implemented Display
manually, then you need to manually check if the user passed in pretty-printing
as a parameter and then change your formatting based on that.
You can check it using formatter.alternate()
in your Display
implementation.
- Did this issue arise out of nowhere, or after an update (of the driver,
server, and/or Rust)?
The issue has likely existed for as long as the crate has. - Are there multiple ways of triggering this bug (perhaps more than one
function produce a crash)?
Nope. Only one, specifically. Formatting with{:#?}
produces correctly-formatted output. - If you know how to reproduce this bug, please include a code snippet here:
let my_hashmap = HashMap::from([
("hello", "world!")
]);
let bson_document = bson::to_document(&my_hashmap);
// Incorrect formatting:
println!("{bson_document:#}");
// This, however, is correctly formatted:
println!("{bson_document:#?}");
// It is probably correctly formatted because the derive(Debug) implementation was used.
Thank you.
Metadata
Metadata
Assignees
Labels
tracked-in-jiraTicket filed in Mongo's Jira systemTicket filed in Mongo's Jira system