microsoft / rust-for-dotnet-devs

Rust for C#/.NET Developers
https://microsoft.github.io/rust-for-dotnet-devs/latest/
Other
353 stars 51 forks source link

enums.md: Rename from_i32 to try_from_i32 #63

Closed cassidoxa closed 7 months ago

cassidoxa commented 7 months ago

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.