Curriculum Data modeling Structs and impl blocks exercise 3 · mcq
Structs and impl blocks
Inside impl Point, a constructor fn new(x: f64, y: f64) returns
a Point. Pick the idiomatic return type.
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.