Curriculum Foundations Scalar types
Scalar types
TypeScript gives beginners one number; Rust asks what number you mean. This theme introduces signed and unsigned integers, usize, f32 and f64, bool, char, explicit casts with as, and the lack of implicit numeric conversion. Planned exercises: 1. choose i32 for an integer. 2. choose f64 for a float. 3. recognise usize for indexes and lengths. 4. fill a boolean type. 5. fill a cast. 6. write an annotated numeric binding. 7. write a safe length comparison. 8. translate TS numeric code with explicit Rust types. 9. fix a mixed-integer compile error.
Exercises
9 ready
01
pick one
Pick the idiomatic Rust binding for a small whole number. Rust
02
pick one
Pick the idiomatic Rust binding for a fractional number. Rust's
03
pick one
.len() and array indexing both work with usize. Pick the right
04
fill blanks
Fill the Rust boolean type. Four letters.
05
fill blanks
Rust requires an explicit keyword to convert between numeric types
06
type one line
Write the Rust line that declares temp as a 64-bit float
07
type one line
Write the boolean line — the answer should be true when the
08
write a program
Translate the TypeScript into a complete Rust program with explicit
09
write a program
The TS reference adds an i32 to an i64. Rust rejects that