Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main(){
- let s = "This is a string";
- let subst1 = s[10..16].to_string().clone();
- let subst2 = s[10..].to_string().clone();
- println!("{}", subst1 == subst2);
- let doublesub = subst1 + &subst2;
- println!("{}", doublesub);
- // Using split iterator to print word by word
- for tempstr in s.split(' ') {
- println!("{}", tempstr);
- }
- // Another useful function of the split iterator
- // collect() Creates a vector ~["This", "is", "a", "string"]
- let wordvec: Vec<&str> = s.split(' ').collect();
- for &s in wordvec.iter() {
- println!("{}", s);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement