当前位置:网站首页>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
边栏推荐
- String function in MySQL
- 云原生虚拟化:基于 Kubevirt 构建边缘计算实例
- Welcome to the markdown editor
- I/O多路复用及其相关详解
- 2022 judgment questions and answers for operation of refrigeration and air conditioning equipment
- [UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)
- The ultimate experience, the audio and video technology behind the tiktok
- Crawler for querying nicknames and avatars based on qqwebapi
- Dock installation redis
- GDAL + ogr learning
猜你喜欢

Classification of cifar100 data set based on convolutional neural network

The ultimate experience, the audio and video technology behind the tiktok

Operation of 2022 mobile crane driver national question bank simulation examination platform

2022 Jiangxi Photovoltaic Exhibition, China distributed Photovoltaic Exhibition, Nanchang solar energy utilization Exhibition

Operators in C language

Cloud native Virtualization: building edge computing instances based on kubevirt

SSD硬盘SATA接口和M.2接口区别(详细)总结

2022 tea artist (primary) examination simulated 100 questions and simulated examination

cv_ Solution of mismatch between bridge and opencv

Welcome to the markdown editor
随机推荐
Theory and practice of laser slam in dark blue College - Chapter 2 (odometer calibration)
C1小笔记【任务训练篇二】
C network related operations
Click Cancel to return to the previous page and modify the parameter value of the previous page, let pages = getcurrentpages() let prevpage = pages [pages. Length - 2] / / the data of the previous pag
Nodejs安装
GDAL + ogr learning
Read excel, int digital time to time
Format problems encountered in word typesetting
undefined reference to `Nabo::NearestNeighbourSearch
SSD硬盘SATA接口和M.2接口区别(详细)总结
Submit local warehouse and synchronize code cloud warehouse
Implementation of image recognition code based on VGg convolutional neural network
Summary of common server error codes
k8s之实现redis一主多从动态扩缩容
journal
xlsxwriter. exceptions. Filecreateerror: [errno 13] permission denied
Go语言JSON包使用
Operators in C language
idea中安装YapiUpload 插件将api接口上传到yapi文档上
Summary of floating point double precision, single precision and half precision knowledge