← 返回起始笔记位置

知识卡片

普通读书笔记卡 · 10883.b.1.d · 生成模型:未记录

字符串按内容比较与处理

理解等级:初级

两个字符串即使来自不同缓冲区,只要内容相同,== 就成立。文本操作直接按用途选 str 方法:contains 检查子串,replace 产生替换后的文本,trim 修剪首尾空白,split 迭代各片段,starts_with 判断前缀。示例 "veni, vidi, vici".split(", ") 每次取得一个词。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第02章《Fundamental Types》|比较文本与识别字符,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch02.xhtml#using-strings` - 结论依据:原文用小写转换断言说明值比较,并展示查找、替换、修剪、切分与前缀检查。 - 原始内容:are equal if they contain the same characters in the same order (regardless of whether they point to the same location in