Guest User

Untitled

a guest
Jun 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. Attempted to access a non-existent field in a struct.
  2. Erroneous code example:
  3.  
  4. ```
  5. struct StructWithFields {
  6. x: u32,
  7. }
  8.  
  9. let s = StructWithFields { x: 0 };
  10. println!("{}", s.foo); // error: no field `foo` on type `StructWithFields`
  11. ```
  12.  
  13. To fix this error, check that you didn't misspell the field's name or that the
  14. field actually exists. Example:
  15.  
  16. ```
  17. struct StructWithFields {
  18. x: u32,
  19. }
  20.  
  21. let s = StructWithFields { x: 0 };
  22. println!("{}", s.x); // ok!
  23. ```
Add Comment
Please, Sign In to add comment