Skip to content

Conversation

isabelatkinson
Copy link
Contributor

This also has the changes from #1103, filtering by the last commit will show the relevant changes for this PR.

Comment on lines +22 to +25
let mut models_vec = Vec::new();
for model in models.into_iter() {
models_vec.push(model.into());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think models.into_iter().map(Into::into).collect() will do two passes, did a manual impl here to be safe

#[derive(Clone, Debug, Serialize)]
#[serde(untagged)]
#[non_exhaustive]
pub enum WriteModel {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypedBuilder doesn't work for enums with directly-embedded fields

@isabelatkinson isabelatkinson marked this pull request as ready for review May 15, 2024 22:45
@isabelatkinson isabelatkinson requested a review from abr-egn May 15, 2024 22:45
{
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
enum WriteModelHelper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this impl still needed? This looks equivalent to what I think #[derive(Deserialize)] on WriteModel would produce now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this limitation still holds unfortunately, the test files use a "tagged" representation whereas the ops array doesn't

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derp, right.

@isabelatkinson isabelatkinson merged commit d895a6d into mongodb:main May 16, 2024
@isabelatkinson isabelatkinson deleted the model-builders branch May 17, 2024 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants