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

Rust code looks pretty good - minor nits #1

Merged
merged 1 commit into from
Feb 29, 2024
Merged

Conversation

aorenste
Copy link
Contributor

These are my suggestions - they're all pretty minor however. The biggest one is just the use of Result + ? in main - getting used to the rust style of error handling is pretty key since it's pretty pervasive.

Copy link
Owner

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

Thanks a lot!!

@@ -217,7 +218,7 @@ struct EmptyMetadata {}

#[derive(Debug, Deserialize)]
struct DynamoOutputGraphMetadata {
sizes: Option<FxHashMap<String, Vec<SymInt>>>,
_sizes: Option<FxHashMap<String, Vec<SymInt>>>,
Copy link
Owner

Choose a reason for hiding this comment

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

Does this change serde's behavior? I need the field to match what I am getting in the JSON format

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 will change the field name - so if you need it to match the JSON name then you can prefix it with:

#[allow(dead_code)]
sizes: Option<FxHashMap<String, Vec<SymInt>>>,

so it doesn't complain about the unread field.

Copy link
Owner

Choose a reason for hiding this comment

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

ok, i'll need to do this. fortunately these are all defaulted so it doesn't matter too much yet

.map_or(format!("unknown_{}", lineno), |e: CompileId| {
format!("{}_{}_{}", e.frame_id, e.frame_compile_id, e.attempt)
});
.as_ref()
Copy link
Owner

Choose a reason for hiding this comment

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

ohhhh lol

frame_id,
frame_compile_id,
attempt,
}| { format!("{frame_id}_{frame_compile_id}_{attempt}") },
Copy link
Owner

Choose a reason for hiding this comment

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

huh, f-string style is nice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just be aware that it only works with identifiers - so you can't do:

format!("{foo.bar}")

but you can do:

format!("{myvar}", myvar = foo.bar)

@ezyang ezyang merged commit 67b3d7d into ezyang:main Feb 29, 2024
6 checks passed
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