rewrite os rand in rust