Hacker News new | past | comments | ask | show | jobs | submit
A Rust library likely wouldn't be returning an opaque Box<dyn Error> to begin with. Errors are part of a library's API—it's what allows consumers to handle them—so you'd define an enum of possible errors your library could produce and return that, which would be stored on the stack.
What about the data in the error payload?
That's part of the error enum.

  enum AllocError {
    SizeTooLarge { size: usize },
    // etc.
  }
This enum has a known size and doesn't require any dynamic allocations.