Rust Cheatsheet#
字符串类型互转 [1]#
let s: String = ...
let st: &str = ...
let u: &[u8] = ...
let b: [u8; 3] = b"foo"
let v: Vec<u8> = ...
let os: OsString = ...
let ost: OsStr = ...
From |
To |
Use |
Comment |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
via |
|
|
|
|
|
|
|
alt. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte literal |
|
|
|
alternative via utf8 literal |
|
|
|
via |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
via |
|
|
|
Unicode replacement characters |
|
|
|
|
|
|
|
|
|
|
|
returns original |
|
|
|
|
|
|
|
|
|
|
|
|
如果你有任何意见,请在此评论。 如果你留下了电子邮箱,我可能会通过 回复你。