rust code performance optimization