result icon indicating copy to clipboard operation
result copied to clipboard

Replace void-OK with dummy structs

Open vorot93 opened this issue 9 years ago • 0 comments

Right now this library contains two versions of Result: one with normal Ok enum and another with void one.

It may be a short-term convenience for callers (simple Ok() suffices if there's nothing of value to return). However:

  • Essentially there are two versions of each struct and function: double effort for maintenance
  • void is an incomplete type and thus presents distant problems for callers (like #6)

Which begs a question: do we really need special casing for void? My proposal is:

  • Bar void from Ok
  • Provide a dummy type alias for empty tuple (std::tuple<>) / empty struct (struct {}) and relevant Ok (using OK = Ok<Dummy>)
  • Include special macro for convenient lambda creation (e.g. DUMMY_CB for [&](const Dummy&)

This will lead to a closer-to-Rust Ok construction in the form of OK({}) and eliminate any void-related template issues.

vorot93 avatar Jan 14 '17 18:01 vorot93