『多コピーの原罪』2022/3/26 7:27:00 https://blog.ojisan.io/many-copies-original-sin/ 目次 Rust は GC を持たないGC とはRust には GC がないClone と Copy とヒープについてコピーできるもの・できないものヒープに入るものは Copy しないヒープにあるものを Clone するとどうなるかRust における文字の種類スライスcharバイト列String&strRust で文字列を扱うためのプラクティスイージーなやり方: すべて Stringよくやるやり方: 戻り値だけ String入力を汎用的にする: Into理想的なやり方: 戻り値も &strライフタイム付きの参照で zero-copy の実現いい感じに抽象化できるスマートポインタ、CoWまとめ、感想、お気持ち
lines2022/2/23 23:56:00 文字列を行ごとに繰り返すメソッド let s = String::from("\ Rust: safe, fast, productive. Pick three."); for line in s.lines() { println!("{}", line); }
to_lowercase2022/2/23 23:55:00 文字列を小文字にするメソッド assert_eq!("Rust".to_lowercase(), "rust"); assert_eq!(String::from("Rust").to_lowercase(), String::from("rust"));
contents2022/2/23 23:37:00 文字列にクエリ文字列を含むか確認するメソッド let s = String::from("safe, fast, productive."); println!("{}", s.contains("duct")); //true let s = "safe, fast, productive."; println!("{}", s.contains("duct")); //true