Question Details

No question body available.

Tags

rust traits api-design unsafe

Answers (1)

January 7, 2026 Score: 0 Rep: 65,546 Quality: Low Completeness: 40%

I don't see an issue with option 1. I'm not sure what scenarios you are considering where handling a T needs to be a specific value for it to be safe but if so the end user is already in unsafe territory. The responsibility should fall on them. Documenting that the value provided initially is what will be given to the consumer (assuming that's what your API does) is good enough if they want to rely their safety invariants on it.