Skip to content
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

associated types for arguments in Input #1234

Merged
merged 2 commits into from
Mar 19, 2024
Merged

associated types for arguments in Input #1234

merged 2 commits into from
Mar 19, 2024

Conversation

davidhewitt
Copy link
Contributor

Change Summary

Continuing with #1230

This time we move GenericArguments to have associated types.

Related issue number

N/A

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes where applicable
  • Pydantic tests pass with this pydantic-core (except for expected changes)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Self: 'a;
fn len(&self) -> usize;
fn get_item<'k>(&self, key: &'k LookupKey) -> ValResult<Option<(&'k LookupPath, Self::Item<'_>)>>;
fn iter(&self) -> impl Iterator<Item = ValResult<(Self::Key<'_>, Self::Item<'_>)>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the return-position-impl-trait-in-trait which requires Rust 1.76 for the MSRV bump. If we wanted to avoid that we probably can use associated types but it'll be gross by comparison (or we can Box and suffer an allocation).

Copy link

codspeed-hq bot commented Mar 19, 2024

CodSpeed Performance Report

Merging #1234 will not alter performance

Comparing dh/input-assocs (0197230) with main (0587e15)

Summary

✅ 148 untouched benchmarks

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

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

This looks really good, nice to get rid of some of those macros.

The last two big ones I think are in model_fields.rs and typed_dict.rs

pos_value = $get_macro!(args, index);
}
// go through fields getting the value from args or kwargs and validating it
for (index, field) in self.fields.iter().enumerate() {
Copy link
Member

Choose a reason for hiding this comment

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

it's pretty hard to review but I assume very little changed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep if you hide whitespace from the diff it's a lot easier to see what changed.

@davidhewitt davidhewitt merged commit abff9ba into main Mar 19, 2024
28 checks passed
@davidhewitt davidhewitt deleted the dh/input-assocs branch March 19, 2024 15: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