Rust 介绍
Rust 是 Mozilla 的一个新的编程语言,由web语言的领军人物Brendan Eich(js之父),Dave
Herman以及Mozilla公司的Graydon Hoare 合力开发。
创建这个新语言的目的是为了解决一个很顽疾的问题:软件的演进速度大大低于硬件的演进,软件在语言级别上无法真正利用多核计算带来的性能提升。Rust是针对多核体系提出的语言,并且吸收一些其他动态语言的重要特性,比如不需要管理内存,比如不会出现Null指针等等。
特点:
-
零成本的抽象
-
移动语义
-
保证内存安全
-
线程没有数据竞争
-
trait-based泛型
-
模式匹配
-
类型推断
-
最小运行时
-
高效的C绑定
// This code is editable and runnable!
fn main() {
// A simple integer calculator:
// + or - means add or subtract by 1
// * or / means multiply or divide by 2let program = ”+ + * - /”;
let mut accumulator = 0;for token in program.chars() {
match token {
’+’ => accumulator += 1,
’-‘ => accumulator -= 1,
’‘ => accumulator = 2,
’/’ => accumulator /= 2,
_ => { / ignore everything else / }
}
}println!(“The program "{}" calculates the value {}”,
program, accumulator);
}
Rust 官网
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。