0

I have a struct where all fields are private, because they should be set using public setters.

It feels awkward to document the setter with a description of the field it sets.

Is there a way to document and show a private field on rustdoc?

Jonathan Woollett-light
  • 2,813
  • 5
  • 30
  • 58
  • 2
    Just document the setters. It's the convention, it makes it possible for you to change the actual fields in the future without changing your interface, you can document your preconditions, etc. Document your interface (public methods), not the way the data is stored (private fields) and don't assume that there is a 1-to-1 relation between setters and fields. – mcarton Feb 26 '20 at 10:30
  • 1
    Why not document both ? IMO both should have different documentation one is for lib user other is for lib maintainer. – Stargateur Feb 26 '20 at 12:33

0 Answers0