![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
rust
文章平均质量分 66
ZHANGJNWEI
这个作者很懒,什么都没留下…
展开
-
rust --hashmap学习
hash map: HashMap<K, V>存储映射关系:类型K 到 类型V的映射;实现中使用hashing函数,决定key和value在内存中如何安置; 创建: hash map存储data在heap上; using std::collections::HashMap; let mut scores = HashMap::new(); scores.insert(String::from("Blu")...原创 2021-08-09 07:56:28 · 438 阅读 · 0 评论 -
rust --String学习
实现Display trait的类型调用to_string()直接转换为String; 创建: let mut s = String::new(); 或者 let data = "Initial content"; let s = data.to_string(); // 创建一个String包含initial content; 或者 let s = String::from("initi...原创 2021-08-09 07:20:55 · 401 阅读 · 0 评论 -
rust --vector 学习
list structure: 存储在heap中; Vec<T> 创建对象:let v: Vec<i32> = Vec::new(); 推断Vec类型:vec!宏; let v = vec![1, 2, 3]; 更新一个vector: let mut v = Vec::new(); v.push(5); v.push(6); v.push(7); ...原创 2021-08-09 06:56:15 · 360 阅读 · 0 评论 -
Rust模块系统管理
Rust referred to as the module system, include: Packages: A Cargo feature that lets you build, test, and share crates Crates: A tree of modules that produces a library or executable Modules and use: Let you control the organization, scope, and...原创 2021-07-27 18:11:05 · 228 阅读 · 0 评论 -
rust所有权概念
rust中所有权概念: 主要涉及内存的管理;rust的编译器在编译时使用规则集,规则集的所有权的系统管理内存; 所有权规则: 在rust中的值有一个变量称作owner;每次只有一个owner;owner超出范围,值被丢弃; 变量范围: scope用来描述变量的有效性的概念,它是一个范围。 { let mut name = String::from("name: ");...原创 2020-07-31 18:30:12 · 263 阅读 · 1 评论 -
rust基本类型和控制
变量: 默认是只读,避免并发时出现的数据异常。 mut关键字说明变量可修改; 阴影模式,let定义一个变量后,再重复定义不会出现编译时错误,例如 let x = 5; let x = 1 + x; let x = 2 + x; 常量定义 const MAX_CONNS: u32 = 100_000; // 常量中的_提升代码可读性 数据类型: scalar: 整型:符号型:i8,i16,i32,i64,i128...原创 2020-07-31 18:29:41 · 200 阅读 · 0 评论 -
rust简单案例
--------Cargo.toml--------------------------- [package] // 块头 name = "hello_cargo" // 剩余4行配置信息 version = "0.1.0" authors = ["Your Name <you@example.com>"] edition = "2018" [dependencies] // 依赖的开始 --------------------------------------------- .原创 2020-07-31 15:35:28 · 211 阅读 · 0 评论 -
rust和cargo基础用法
rust安装: CentOS: $ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh 更新: $ rustup update 删除: $ rustup self uninstall 检查rust安装 $ rustc --version ------------------------------------------------------------------------- 简...原创 2020-07-31 15:34:01 · 1016 阅读 · 0 评论