title: Why is Vec::len a method instead of a public property?
body: <p>I noticed that Rust's <code>Vec::len</code> method just accesses the vector's <code>len</code> property. Why isn't <code>len</code> just a public property, rather than wrapping a method around it?</p>
  <p>I assume this is so that in case the implementation changes in the future, nothing will break because <code>Vec::len</code> can change the way it gets the length without any users of <code>Vec</code> knowing, but I don't know if there are any other reasons.</p>
  <p>The second part of my question is about when I'm designing an API. If I am building my own API, and I have a struct with a <code>len</code> property, should I make <code>len</code> private and create a public <code>len()</code> method? Is it bad practice to make fields public in Rust? I wouldn't think so, but I don't notice this being done often in Rust. For example, I have the following struct:</p>
  <pre><code>pub struct Segment {
      pub dol_offset: u64,
      pub len: usize,
      pub loading_address: u64,
      pub seg_type: SegmentType,
      pub seg_num: u64,
  }
  </code></pre>
  <p>Should any of those fields be private and instead have a wrapper function like <code>Vec</code> does? If so, then why? Is there a good guideline to follow for this in Rust?</p>