Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
This story was originally published on Medium
Casting in Rust
Casting means changing the data type of a piece of data from one type to another.
as keyword turns primitive types into other primitive types. We can use
as keyword to solve the code in the introduction.
When you cast from a small length to a larger length, for example from 8-bit to 16-bit, there won’t be any problem but when you cast down, you may have a problem.