-
Notifications
You must be signed in to change notification settings - Fork 177
RUST-1858 Add builders for bulk write models #1104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
let mut models_vec = Vec::new(); | ||
for model in models.into_iter() { | ||
models_vec.push(model.into()); | ||
} |
There was a problem hiding this comment.
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
@@ -32,66 +36,205 @@ pub struct BulkWriteOptions { | |||
#[serde(untagged)] | |||
#[non_exhaustive] | |||
pub enum WriteModel { |
There was a problem hiding this comment.
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
@@ -31,136 +38,22 @@ impl<'de> Deserialize<'de> for WriteModel { | |||
#[derive(Debug, Deserialize)] | |||
#[serde(rename_all = "camelCase")] | |||
enum WriteModelHelper { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derp, right.
8f15330
to
0366337
Compare
This also has the changes from #1103, filtering by the last commit will show the relevant changes for this PR.