Closed ricardosc12 closed 4 months ago
Hey @ricardosc12! #[non_exhaustive]
is required for future-proofing against possible field additions, although I understand that this makes it challenging to mock results. RUST-1891 was filed by another user to add Default
to these structs to make it possible to construct them outside of the crate. This likely won't be prioritized by the team in the near future, but we'd be happy to review a PR if you'd like to work on this yourself!
Thank you for your understanding, and I'm glad this has already been reported, even though it's not currently in your plans to implement it. I will consider evaluating a contribution towards this. Thanks!
I'm currently writing unit tests for a web service using the Rust MongoDB Driver. As part of these tests, I aim to mock both input and return data without actually querying a database.
However, MongoDB marks its operation result structs as #[non_exhaustive]. This prevents direct instantiation when mocking these structs.
Wouldn't it be beneficial to allow users to handle potential versioning issues themselves in the case of operation results structs?
https://stackoverflow.com/questions/78760352/handling-non-exhaustive-structs-in-rust-unit-tests-with-mongodb-and-axum?noredirect=1#comment138862853_78760352