Change unsafe functions to safe functions
auto merge of #6488 : sammykim/rust/issue-6430, r=sanxiyn

Fix issue #6430.