2 ms·
Expanding a bit on conversions: C#'s `Convert` conflates several different operations. Examples: Convert.ToInt32(String) – This is _parsing_. In Rust, use `pa
by johnsoft 6y ago
Expanding a bit on conversions: C#'s `Convert` conflates several different operations.
Examples:
Convert.ToInt32(String) – This is _parsing_. In Rust, use `parse`.
Convert.ToString(Int32) – This is _stringifying_. In Rust, use `to_string`.
Convert.ToInt64(Int32) – This is an _infallible conversion_. In Rust, use `into`.
Convert.ToInt32(Int64) – This is a _fallible conversion_. In Rust, use `try_into`.
In all these cases, Rust gives you more immediate semantic information about the conversion, and in fewer characters too!