惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
News and Events Feed by Topic
AI
AI
S
Secure Thoughts
Schneier on Security
Schneier on Security
Help Net Security
Help Net Security
N
News | PayPal Newsroom
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News: Ask HN
Hacker News: Ask HN
W
WeLiveSecurity
Google Online Security Blog
Google Online Security Blog
T
Tailwind CSS Blog
Jina AI
Jina AI
小众软件
小众软件
S
Security @ Cisco Blogs
A
About on SuperTechFans
雷峰网
雷峰网
T
Threat Research - Cisco Blogs
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
AWS News Blog
AWS News Blog
The Register - Security
The Register - Security
V
Visual Studio Blog
PCI Perspectives
PCI Perspectives
Blog — PlanetScale
Blog — PlanetScale
L
LINUX DO - 最新话题
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 叶小钗
P
Proofpoint News Feed
美团技术团队
F
Fortinet All Blogs
NISL@THU
NISL@THU
T
Troy Hunt's Blog
U
Unit 42
博客园 - Franky
B
Blog
Webroot Blog
Webroot Blog
T
The Exploit Database - CXSecurity.com
The Hacker News
The Hacker News
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Google DeepMind News
Google DeepMind News
P
Privacy & Cybersecurity Law Blog
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI

KuangjuX(狂且)

提高 Directory Cache 性能 高速缓存技术(Cache) Chisel 学习笔记 随笔(一) 指令级并行技术 TLB MMU 笔记(基于 MIPS) Verilator 学习笔记 MIT-6.S081-mmap MIT-6.S081 Networking MIT-6.S081 Lazy Page Allocation MIT-6.S081 Copy on Write Fork MIT-6.S081 User Level Threads 2021年终总结 xv6-riscv中的KPTI机制 RISC -V N扩展 io_uring 阅读笔记 在Ubuntu中升级Linux内核 飞书Rust实习面试 Rust并发安全总结
Rust String 用法总结
KuangjuX · 2021-10-19 · via KuangjuX(狂且)
  • String + String -> String:
1
2
3
let s1 = "0";
let s2 = "1";
let s = format!("{}{}", s1, s2);
  • String + &str -> String:
1
2
3
let s1: &str;
let s: String;
s.push_str(s1);
  • &str + &str -> String:
1
2
3
4
let s1: &str;
let s2: &str;
let s = String::from_str(s1);
s.push_str(s2);
  • String -> &str:
1
2
3
let s: String;
let s1: &str = s.as_str();
let s2: &mut str = s.as_mut_str();
  • String -> &[u8]:
1
2
let s: String;
let s1: &[u8] = s.as_bytes();
  • String -> &mut Vec< u8 >
1
2
let s: String
let s1: &mut Vec<u8> = s.as_mut_vec();
  • &str -> String:
1
2
let s: &str;
let s1 = String::from_str(s);
  • &[u8] -> String:
1
2
3
let s: &[u8];
let s1 = String::from_utf8_lossy(s);
let s2 = String::from_utf8(s.to_vec()).unwrap();
  • Vec< u8 > -> String:
1
2
let s: Vec<u8>;
let s1 = String::from_utf8(s).unwrap();
  • 通过索引获取 String 中的 字符
1
2
let s: String;
let c = s.chars().nth(index).unwrap();
  • 遍历 String
1
2
3
4
let s: String;
for c in s.chars() {

}

Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.