In general, the benefit of using from instead of as where possible is that it prevents bugs when refactoring - here's a (somewhat contrived) example:
fn test(input: u8) {
let x = input as i32;
let y = i32::from(input);
}
What happens if I later decide to change the type of input to f32?
-
xsilently gets truncated, becauseascan be a lossy operation. -
ythrows a compile error, as the standard library does not implementFromfor lossy numeric conversions.
So that's the main difference (and why Clippy nudges you to use the latter) - they don't behave differently in this case, but it makes sure that the compiler will let you know if you accidentally change the behavior.