google/zerocopy

Make as much of zerocopy as possible work in a const context

joshlf opened this issue · 0 comments

Currently, most of zerocopy's abstractions don't work in a const context for one reason or another. We should change that as much as possible.

This is a blocker for ICU4X using zerocopy.

Trait methods

One large subset of the API is the set of trait methods. Most or all of these don't rely on calling other trait methods, but effectively just use the trait bound to guarantee that the operation is sound. This entire subset in principle ought to be representable as bare functions, and many of them would likely be convertible into const fns. We could of course keep the trait methods as well, and just implement them in terms of the functions.

This approach has two big downsides:

  • It would effectively duplicate a large subset of our API surface
  • We would probably want to remove the bare functions in a future release once all of the trait methods could themselves be const (it's not clear to me how far off this is)