Curriculum Foundations Hello and printing
Hello and printing
Rust prints with a macro, not a function. println! (note the !) writes to stdout with a trailing newline; print! is the no-newline variant. Format placeholders use {} instead of TypeScript's template-literal ${...}. Macros, format strings, and the no-newline-by-default print! are the three reflex shifts here. Planned exercises: 1. choose fn main(). 2. choose println!. 3. recognise macro calls by !. 4. fill the println! macro name. 5. fill a {} format placeholder. 6. write one print line. 7. write a formatted greeting. 8. translate a complete hello program. 9. write a tiny program that prints two lines.
Exercises
9 ready
01
pick one
TypeScript can run top-level statements in a script. Rust binaries
02
pick one
TypeScript calls console.log. Rust's common stdout helper is a
03
pick one
Rust format strings use {} placeholders. Pick the Rust translation
04
fill blanks
Fill the macro name that prints one line to stdout.
05
fill blanks
Fill the Rust format placeholder that receives the value after the
06
type one line
Type the Rust line that prints Hi followed by a newline.
07
type one line
The scaffold already binds name. Type the Rust line that prints
08
write a program
Translate the TypeScript into a complete Rust program.
09
write a program
Write a Rust program that prints two lines: first and then