当前位置:网站首页>Refcell in rust
Refcell in rust
2022-04-23 18:03:00 【Xu Yeping】
RefCell And Cell Basically the same , The difference lies in RefCell When reading content , The return is the reference , It's essentially a pointer . This is because RefCell The data to be packaged is not implemented Copy characteristic . The code example is as follows :
use std::cell::{
Ref, RefCell};
fn main() {
let x = RefCell::new("good".to_string());
let a = &x;
let b = &x;
*a.borrow_mut() = "nice".to_string();
*b.borrow_mut() = "best".to_string();
let y: Ref<String> = x.borrow();
println!("x = {:?}", x);
println!("y = {:?}", y);
}
---------------------------------------------------
>cargo run
x = RefCell {
value: "best" }
y = "best"
rust This set of tools is really beautiful !
版权声明
本文为[Xu Yeping]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230544498524.html
边栏推荐
- Auto.js 自定义对话框
- Arcpy adds fields and loop assignments to vector data
- Welcome to the markdown editor
- 2022江西光伏展,中国分布式光伏展会,南昌太阳能利用展
- 2022 judgment questions and answers for operation of refrigeration and air conditioning equipment
- 2022 tea artist (primary) examination simulated 100 questions and simulated examination
- Install pyshp Library
- Halo 开源项目学习(二):实体类与数据表
- Docker 安装 MySQL
- JS get link? The following parameter name or value, according to the URL? Judge the parameters after
猜你喜欢
![[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (1)](/img/74/bb173ca53d62304908ca80d3e96939.png)
[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (1)

Implementation of image recognition code based on VGg convolutional neural network
![[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)](/img/ae/cbfc01fbcc816915b1794a9d70247a.png)
[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)

Go's gin framework learning

MySQL auto start settings start with systemctl start mysqld

Go的Gin框架学习

Calculation of fishing net road density

2022 Jiangxi energy storage technology exhibition, China Battery exhibition, power battery exhibition and fuel cell Exhibition

QTableWidget使用讲解

Map basemap Library
随机推荐
Crawl lottery data
word frequency count
Transfer learning of five categories of pictures based on VGg
Dock installation redis
k8s之实现redis一主多从动态扩缩容
xlsxwriter. exceptions. Filecreateerror: [errno 13] permission denied
Yolov4 pruning [with code]
ES6 face test questions (reference documents)
re正则表达式
Climbing watermelon video URL
A few lines of code teach you to crawl lol skin pictures
.104History
Realization of consumer gray scale
Docker 安装 Redis
Summary of floating point double precision, single precision and half precision knowledge
Map basemap Library
Amount input box, used for recharge and withdrawal
Detailed deployment of flask project
[UDS unified diagnostic service] (Supplement) v. detailed explanation of ECU bootloader development points (2)
ES6