-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add .arch function #166
Add .arch function #166
Conversation
/// Return the arch string for the platform | ||
/// The arch is usually the part after the `-` of the platform string. | ||
/// Only for 32 and 64 bit platforms the arch is `x86` and `x86_64` respectively. | ||
pub fn arch(&self) -> String { |
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.
Can we do this without the unwrap? especially if we get “unknown”. Maybe return option?
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.
Good point, especially for noarch
it should be undefined :)
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 would also prefer to write out the match statement. And only use the string split for the unknown case. That way you depend less on the to string implementation which seems a bit cleaner.
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.
Yeah I do think that's good, but it also makes us have the same data in two places which is what I dislike... but I can write it out and we could add a test or something.
Just for the record, I've also looked at implementing a custom platform (that would be Or is there a copyable string somewhere that we could/should use? |
Note:
I also had a version that wrote out all options
We could also implement a stricter type for
Arch
I think we should also implement a catch-all platform (
Unknown(String)
) to facilitate adding new platforms easily