JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

[Rust] Option

发布时间 2023-05-24 01:29:53作者: Zhentiw

Typescript:

function practice(nums: number[], index: number): number {
    return (nums[index] ?? index) * 5
}

 

In Rust:

fn practice(nums: Vec<usize>, index: usize) -> uszie {
  return nums.get(index).unwrap_or(&index) * 5;
}

 

    本栏目推荐文章
  • 学习 Rust 的 15 种方法
  • mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; ERROR 1410 (42000): You are not allowed to create a user with GRANT
  • [Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".
  • Rust 从入门到摔门而出门 环境安装 和 Hello, world!
  • Rust 使用包、Crate 和模块管理不断增长的项目
  • 40. 干货系列从零用Rust编写负载均衡及代理,websocket的实现
  • Rust 枚举和模式匹配
  • rust angular 自签名证书 wss
  • 39. 干货系列从零用Rust编写负载均衡及代理,正则及格式替换
  • Clion 中 Rust 插件开启 WSL 调试
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们