当前位置:网站首页>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
边栏推荐
- Docker 安装 Redis
- undefined reference to `Nabo::NearestNeighbourSearch
- The ultimate experience, the audio and video technology behind the tiktok
- 2022 tea artist (primary) examination simulated 100 questions and simulated examination
- C1 notes [task training part 2]
- C1小笔记【任务训练篇一】
- proxy server
- 20222 return to the workplace
- Cloud native Virtualization: building edge computing instances based on kubevirt
- How to read literature
猜你喜欢

Theory and practice of laser slam in dark blue College - Chapter 2 (odometer calibration)
![Yolov4 pruning [with code]](/img/09/ea4376d52edb7e419ace2cb1e0356b.gif)
Yolov4 pruning [with code]

Install pyshp Library
![[UDS unified diagnostic service] v. diagnostic application example: Flash bootloader](/img/45/f9e24ae1c619f78aeeb7bcf12d6e5f.png)
[UDS unified diagnostic service] v. diagnostic application example: Flash bootloader

Nat commun | current progress and open challenges of applied deep learning in Bioscience

Open source key component multi_ Button use, including test engineering

positioner

Go file operation

Map basemap Library

How to install jsonpath package
随机推荐
纳米技术+AI赋能蛋白质组学|珞米生命科技完成近千万美元融资
Amount input box, used for recharge and withdrawal
Eigen learning summary
2022 tea artist (primary) examination simulated 100 questions and simulated examination
云原生虚拟化:基于 Kubevirt 构建边缘计算实例
Halo 开源项目学习(二):实体类与数据表
[UDS unified diagnostic service] IV. typical diagnostic service (6) - input / output control unit (0x2F)
Clion installation tutorial
Logic regression principle and code implementation
Arcpy adds fields and loop assignments to vector data
Submit local warehouse and synchronize code cloud warehouse
SSD硬盘SATA接口和M.2接口区别(详细)总结
2022 Jiangxi Photovoltaic Exhibition, China distributed Photovoltaic Exhibition, Nanchang solar energy utilization Exhibition
Auto. JS custom dialog box
.105Location
Selenium + webdriver + chrome realize Baidu to search for pictures
Nat commun | current progress and open challenges of applied deep learning in Bioscience
Batch export ArcGIS attribute table
Random number generation of C #
Docker 安裝 Redis