From 2d729b8befe5f7ac849db12b3e08ac2132994f52 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Tue, 10 Dec 2013 05:47:08 -0800 Subject: [PATCH] Updated Doc FAQ Cheatsheet (markdown) --- Doc-FAQ-Cheatsheet.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Doc-FAQ-Cheatsheet.md b/Doc-FAQ-Cheatsheet.md index 2d72068..08d90b1 100644 --- a/Doc-FAQ-Cheatsheet.md +++ b/Doc-FAQ-Cheatsheet.md @@ -40,6 +40,17 @@ let x: Option = from_str_radix("deadbeef", 16); let y: int = x.unwrap(); ``` +## String operations + +### How do I search for a substring? + +Use the [`find_str`](http://static.rust-lang.org/doc/master/std/str/trait.StrSlice.html#tymethod.find_str) method. + +```rust +let str = "Hello, this is some random string"; +let index: Option = str.find_str("rand"); +``` + ## How do I get the length of a vector? The [`Container`](http://static.rust-lang.org/doc/master/std/container/trait.Container.html) trait provides the `len` method.