Splitting a "impl BigTrait for Foo" over many files


#1

I have something like the following:

  1. BigTrait
pub trait BigTrait {
  fn1(....);
  fn2(....);
...
  fn30(...);
}

(think something like a bunch of blas bindings + other numerical bindings)

  1. Then, I have something like
impl BigTrait for Foo {
...
}

Now, the unforutnate thing is that I have do dump all 30 impls into the same *.rs file. Is there a way to split the “impl BigTrait for Foo” across multiple *.rs files? (without breaking BigTrait itself into multiple smaller traits) ?


#2

Not directly, but you could implement all the methods on BigTrait by simply calling out to other functions, which can be defined elsewhere.

An example of this is the itertools crate, which has a trait with dozens of methods: https://github.com/bluss/rust-itertools/blob/44c9654fdb3653389ddd57048363808de9737381/src/lib.rs#L304