当前位置:网站首页>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
边栏推荐
- 2022江西光伏展,中国分布式光伏展会,南昌太阳能利用展
- 极致体验,揭晓抖音背后的音视频技术
- Thirteen documents in software engineering
- How to read literature
- MySQL auto start settings start with systemctl start mysqld
- Tensorflow tensor introduction
- Go's gin framework learning
- Random number generation of C #
- Fashion classification case based on keras
- positioner
猜你喜欢
极致体验,揭晓抖音背后的音视频技术
C1小笔记【任务训练篇一】
Solving the problem of displaying too many unique values in ArcGIS partition statistics failed
Gaode map search, drag and drop query address
Open source key component multi_ Button use, including test engineering
ArcGIS license error -15 solution
C1 notes [task training part 2]
.104History
Visualization of residential house prices
A few lines of code teach you to crawl lol skin pictures
随机推荐
Summary of floating point double precision, single precision and half precision knowledge
Flash operates on multiple databases
2022 Jiangxi Photovoltaic Exhibition, China distributed Photovoltaic Exhibition, Nanchang solar energy utilization Exhibition
A few lines of code teach you to crawl lol skin pictures
Map basemap Library
C# 网络相关操作
MySQL_ 01_ Simple data retrieval
Amount input box, used for recharge and withdrawal
How to install jsonpath package
Classes and objects
Docker 安装 Redis
YOLOv4剪枝【附代码】
ArcGIS license error -15 solution
Flash - Middleware
Go的Gin框架学习
Clion installation tutorial
Qtablewidget usage explanation
Thirteen documents in software engineering
Yolov4 pruning [with code]
2022 Jiangxi energy storage technology exhibition, China Battery exhibition, power battery exhibition and fuel cell Exhibition