-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
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.
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>>>, |
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.
Does this change serde's behavior? I need the field to match what I am getting in the JSON format
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.
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.
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.
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() |
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.
ohhhh lol
frame_id, | ||
frame_compile_id, | ||
attempt, | ||
}| { format!("{frame_id}_{frame_compile_id}_{attempt}") }, |
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.
huh, f-string style is nice
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.
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)
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.