a basic question: Should functions that omit checks always be declared unsafe?
I have a type
T that holds a certain contract which is tested when a new
T is constructed. However, these tests are expensive, so I want a public API that omits these checks when the programmer can ensure that the contract is valid. Therefore, there is now a
fn new_unchecked(...). However, having an
*_unchecked() method public, it can no longer be guaranteed that every
T holds its contract.
The question is should such methods be declared
unsafe even they do technically nothing unsafe? As far as I'm concerned
unsafe fn refers in Rust to "Could result in memory violation if not used correctly" but my case is more "Could result in unexpected behavior if not used correctly".