glsp icon indicating copy to clipboard operation
glsp copied to clipboard

Consider changing constructors from glsp:: functions into associated functions

Open fleabitdev opened this issue 5 years ago • 0 comments

The glsp namespace is currently cluttered with around 100 toplevel functions. When a new user looks at the docs.rs page, I expect this doesn't make a great first impression. The functions are also quite verbose (glsp:: is six characters), they're not very self-documenting at the call site (glsp::arr_from_iter is debatably less clear than Arr::from_iter), and they introduce name-collision problems in the prelude.

Many of the toplevel constructors could be converted into associated functions. For example, glsp::coro could become Coro::new, and glsp::step_by could become GIter::step_by. A quick headcount suggests that this would eliminate around 40 toplevel functions.

Possible downsides:

  • Most of the constructors would return a Root, which might be counterintuitive
  • This change could make constructors less discoverable
  • It would make the codebase less organised (we would need to add many with_engine invocations outside of engine.rs)

fleabitdev avatar Dec 31 '20 11:12 fleabitdev