How can I convert a usize to u32?
For example I want to store the length of a Vector (usize) to a variable u32 I tried i32::from(v) // or v.into(). where v is the length of the vector but errored
I tried v as u32 and it compiles fine but I am interested in finding the correct way of doing this as this https://stackoverflow.com/questions/28273169/how-do-i-convert-between-numeric-types-safely-and-idiomatically suggests that generally speaking using as instead of from should be avoided
However trying to use from in ink! errors I am guessing because of no std access
Also looking at similar posts like How to convert Vec<u8> to u32 in Substrate runtime? I can see that core::str::from_utf8 was used for a different conversion
So my questions are:
Q1: how to convert usize to u32
Q2: where to read more about conversions between types in ink! e.g. read about examples similar to core:: above