当前位置:网站首页>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
边栏推荐
- C [file operation] read TXT text by line
- 极致体验,揭晓抖音背后的音视频技术
- 2022 Shanghai safety officer C certificate operation certificate examination question bank and simulation examination
- Using files to save data (C language)
- [UDS unified diagnostic service] v. diagnostic application example: Flash bootloader
- How to read literature
- ES6
- JS high frequency interview questions
- Operators in C language
- Implement a simple function to calculate the sum of all integers between M ~ n (m < n)
猜你喜欢

Nodejs安装

Qtablewidget usage explanation

由tcl脚本生成板子对应的vivado工程

idea中安装YapiUpload 插件将api接口上传到yapi文档上

2022 judgment questions and answers for operation of refrigeration and air conditioning equipment

解决允许在postman中写入注释请求接口方法

SSD硬盘SATA接口和M.2接口区别(详细)总结
![C1 notes [task training chapter I]](/img/2b/94a700da6858a96faf408d167e75bb.png)
C1 notes [task training chapter I]
Scikit learn sklearn 0.18 official document Chinese version

Implementation of k8s redis one master multi slave dynamic capacity expansion
随机推荐
MySQL_ 01_ Simple data retrieval
Open source key component multi_ Button use, including test engineering
Excel opens large CSV format data
_ FindText error
Classification of cifar100 data set based on convolutional neural network
Pyppeter crawler
Realsense selection comparison d455 d435i d415 t265 3D hardware comparison
Nat Commun|在生物科学领域应用深度学习的当前进展和开放挑战
An example of linear regression based on tensorflow
word frequency count
Examination question bank and online simulation examination of the third batch (main person in charge) of special operation certificate of safety officer a certificate in Guangdong Province in 2022
Read excel, int digital time to time
消费者灰度实现思路
SSD硬盘SATA接口和M.2接口区别(详细)总结
Docker installation MySQL
Crack sliding verification code
undefined reference to `Nabo::NearestNeighbourSearch
ArcGIS license error -15 solution
解决报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
读取excel,int 数字时间转时间