Curriculum Data modeling Structs and impl blocks exercise 2 · mcq
Structs and impl blocks
Given struct Point { x: f64, y: f64 }, pick the expression
that constructs a Point with x=1.0 and y=2.0.
TypeScript reference
About this theme
Rust separates data declarations from method implementations. A struct names fields; an impl block attaches constructors and methods. Planned exercises: 1. choose struct declaration syntax. 2. recognise named-field literals. 3. choose Self in a constructor. 4. fill an impl block. 5. fill a &self method. 6. write a constructor. 7. write a read-only method. 8. translate a TS object with methods. 9. fix an accidental move out of self.