String matching: Difference between revisions
Content added Content deleted
Line 2,787: | Line 2,787: | ||
<lang rust> |
<lang rust> |
||
fn main(){ |
fn main(){ |
||
let hello = String::from("Hello |
let hello = String::from("Hello world"); |
||
println!(" Start with \"he\" {} \n Ends with \"rd\" {}\n Contains \"wi\" {}", |
println!(" Start with \"he\" {} \n Ends with \"rd\" {}\n Contains \"wi\" {}", |
||
hello.starts_with("He"), |
hello.starts_with("He"), |
||
hello.ends_with(" |
hello.ends_with("ld"), |
||
hello.contains("wi")); |
hello.contains("wi")); |
||
}</lang> |
}</lang> |
||
Line 2,796: | Line 2,796: | ||
{{out}} |
{{out}} |
||
Start with "he" true |
Start with "he" true |
||
Ends with " |
Ends with "ld" true |
||
Contains "wi" false |
Contains "wi" false |
||