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

enums.md: Rename from_i32 to try_from_i32 #63

Merged
merged 1 commit into from
Mar 20, 2024
Merged

enums.md: Rename from_i32 to try_from_i32 #63

merged 1 commit into from
Mar 20, 2024

Conversation

cassidoxa
Copy link
Contributor

A common convention in Rust when converting from one type to another in a fallible way (i.e., when returning a Result,) is to name the function try_from_* instead of from_*, which is used for infallible conversions (we also see this same convention in the From and TryFrom traits.) This lets the programmer know at a glance that they're dealing with a value or a Result.

A common convention in Rust when converting from one type to another in a fallible way (i.e., when returning a Result,) is to name the function "try_from_*" instead of "from_*" which is used for infallible conversions (we also see this same pattern in the From and TryFrom traits.) This lets the programmer know at a glance that they're dealing with a value or a Result.
Copy link
Contributor

@atifaziz atifaziz left a comment

Choose a reason for hiding this comment

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

💯 and thanks for your contribution!

@atifaziz atifaziz merged commit d7408f0 into microsoft:main Mar 20, 2024
3 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