We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
str 类型是硬编码进可执行文件,也无法被修改
str
这一句是比较显然的错误。作者希望表述的应该是字符串字面量,如 "abc" 这样直接包含在源代码中的字符串,其类型为 &'static str。(注意,这并不意味着有 'static 生命周期的 str 就不可变了,仍然有办法构造出具有 'static 生命周期的 &mut str)
"abc"
&'static str
'static
&mut str
然而 str 类型本身是可以修改的,可以试着用 Box<str> 调用 make_ascii_uppercase() 验证。
Box<str>
make_ascii_uppercase()
正如 String 只是 Vec<u8> 的包装,str 也基本上只是 [u8] 的一个子集,[u8] 可变,str 自然也可变,只是依旧要遵循 utf8 编码罢了。
String
Vec<u8>
[u8]
The text was updated successfully, but these errors were encountered:
谢谢提醒,我看一下哈。
Sorry, something went wrong.
No branches or pull requests
这一句是比较显然的错误。作者希望表述的应该是字符串字面量,如
"abc"
这样直接包含在源代码中的字符串,其类型为&'static str
。(注意,这并不意味着有'static
生命周期的str
就不可变了,仍然有办法构造出具有'static
生命周期的&mut str
)然而
str
类型本身是可以修改的,可以试着用Box<str>
调用make_ascii_uppercase()
验证。正如
String
只是Vec<u8>
的包装,str
也基本上只是[u8]
的一个子集,[u8]
可变,str
自然也可变,只是依旧要遵循 utf8 编码罢了。The text was updated successfully, but these errors were encountered: