Curriculum Data modeling Structs and impl blocks exercise 1 · mcq
Structs and impl blocks
Declare a Point with x and y as f64 fields. Pick the
idiomatic Rust syntax.
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.