feat(arrived at types)

This commit is contained in:
2024-08-13 08:54:05 +02:00
commit e8b31ec56e
9 changed files with 564 additions and 0 deletions

20
src/types.rs Normal file
View File

@@ -0,0 +1,20 @@
pub fn types_module() {
// casting with as: types can be casted as long as the types overlap.
let decimal = 65.4321;
let integer: u8 = decimal as u8;
println!("The decimal {} is casted to the u8 {}", decimal, integer);
// dangerous carting can be done with some methods
unsafe {
println!(
"f32 -100.0 as u8 is : {}",
(-100.0_f32).to_int_unchecked::<u8>()
);
}
// type alias are also a thing
type Inch = u64;
let inch: Inch = 5;
println!("using type aliases {}", inch);
}