当前位置:网站首页>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 tea artist (primary) examination simulated 100 questions and simulated examination
- Cross domain settings of Chrome browser -- including new and old versions
- SSD硬盘SATA接口和M.2接口区别(详细)总结
- Welcome to the markdown editor
- Nat commun | current progress and open challenges of applied deep learning in Bioscience
- 列錶的使用-增删改查
- C [file operation] read TXT text by line
- GDAL + ogr learning
- .105Location
- YOLOv4剪枝【附代码】
猜你喜欢

Gaode map search, drag and drop query address

Auto.js 自定义对话框

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

Map basemap Library

Using files to save data (C language)

Transfer learning of five categories of pictures based on VGg

QTableWidget使用讲解

A few lines of code teach you to crawl lol skin pictures

Implementation of image recognition code based on VGg convolutional neural network

2022 Jiangxi energy storage technology exhibition, China Battery exhibition, power battery exhibition and fuel cell Exhibition
随机推荐
How to install jsonpath package
Theory and practice of laser slam in dark blue College - Chapter 2 (odometer calibration)
C1小笔记【任务训练篇二】
Reptile efficiency improvement method
Operation of 2022 mobile crane driver national question bank simulation examination platform
cv_ Solution of mismatch between bridge and opencv
Summary of floating point double precision, single precision and half precision knowledge
20222 return to the workplace
C language array processing batch data
Array rotation
极致体验,揭晓抖音背后的音视频技术
Encapsulate a timestamp to date method on string prototype
idea中安装YapiUpload 插件将api接口上传到yapi文档上
C language loop structure program
word frequency count
Halo open source project learning (II): entity classes and data tables
解决报错max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
MySQL 中的字符串函数
解决允许在postman中写入注释请求接口方法
.105Location