随笔分类 - Rust / Rust基础
摘要:1 Rc(Reference Counted) Rc(Reference Counted):是Rust标准库中,用于处理引用计数的智能指针。用来突破单一所有权的限制。其基本操作是通过clone()增加引用计数。 Reference Counted // Rc会把对应的数据结构创建在堆上 // 堆上的
阅读全文
摘要:原文链接 1、Option - 可空变量 虽然Rust中有null的概念,但是使用null并不是Rust中常见的模式。假设我们要写一个函数,输入一种手机操作系统的名称,这个函数就会返回其应用商店的名称。如果传入字符串iOS,该函数将返回App Store;如果传入字符串android,那么该函数将返
阅读全文
摘要:Most likely, soon after you’ve started your Rust journey, you ran into this scenario where you tried to work with string types (or should I say, you t
阅读全文
摘要:原文链接:A closer look at Ownership in Rust So you want to learn Rust and keep hearing about the concept of Ownership and Borrowing, but can’t fully wrap
阅读全文
摘要:(一)概念 RAII全称是Resource Acquisition Is Initialization,翻译过来是资源获取即初始化,RAII机制用于管理资源的申请和释放。对于资源,我们通常经历三个过程,申请,使用,释放,这里的资源不仅仅是内存,也可以是文件、socket、锁等等。 RAII,它是“R
阅读全文
摘要:原文链接:Moves, copies and clones in Rust Introduction Moves and copies are fundamental concepts in Rust. These might be completely new to programmers com
阅读全文