Skip to content

Commit d6d8769

Browse files
UbuntuUbuntu
authored andcommitted
Add an example of casting error
1 parent a663846 commit d6d8769

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/types/cast.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ fn main() {
2222
let integer = decimal as u8;
2323
let character = integer as char;
2424
25+
// Error! There are limitations in conversion rules. A float cannot be directly converted to a char.
26+
let character = decimal as char;
27+
// FIXME ^ Comment out this line
28+
2529
println!("Casting: {} -> {} -> {}", decimal, integer, character);
2630
2731
// when casting any value to an unsigned type, T,

0 commit comments

Comments
 (0)