Add safer segfault implementation
The current segfault implementation uses unsafe code. Unsafe code is discouraged as it can be a source of bugs, such as possible memory safety issues.
This PR adds a segfault implementation, segfault_safe, which only uses safe Rust. Although this may not be as reliable as the unsafe implementation, the benefit of using no unsafe code is evident.
Also, README.md has been updated to include an example of this implementation
This is cool but I'd say it's arguably less safe because it relies on undefined behaviour in the rust compiler.
This approach tries to use invalid memory and the effect of that is completely platform dependant. Raising a signal, is to my knowledge far less platform-dependant because it doesn't rely on the platform to handle an invalid pointer correctly. Instead, it just directly tells libc to call to call the OS to say something bad happened. I could be wrong on this, my understanding assumes the libc function is sound and implemented correctly on all major platforms, which may not be true. I wouldn't put it past the C standard library to have a sloppy approach, C is well-known for its rampant undefined behaviour.