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

Fix issue #6430