title: How can I split up a large impl over multiple files?
body: <p>I really don't like monolithic implementations of the functions for a class (in C++ speak). In that language I can split things up as I like; in Rust there are strict rules about what goes in what files.</p>
  <p>I have about 2000 lines (no comments/ docs) of <code>impl</code> for a struct. Logically they can be broken up into different sets; functions for managing aspect A, functions for managing aspect B, ... They all noodle on the <code>struct</code>'s data big time, so chopping the <code>struct</code> up further wont help.</p>
  <p>I saw in one answer that you can have</p>
  <pre><code>// in thing.rs
  
  struct Thing{
  .......
  }
  
  impl Thing{
    fn1
    fn2
  }
  </code></pre>
  <pre><code>// in more_thing.rs
  
  use crate::thing::*;
  impl Thing{
    fn3,
    fn4
  }
  </code></pre>
  <pre><code>// in lib.rs
  
  mod thing;
  mod more_thing;
  </code></pre>
  <p>This works, almost (I was surprised it worked at all). Its a kind of half way house. The problem is that for the methods in more_thing.rs I have to declare the fields of <code>Thing</code> all <code>pub</code>. Which is doable but not great. Are there any other options?</p>
  <p>I know I can limit the <code>pub</code> scope but still it blows encapsulation.</p>