Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let novel = String::from("Call me Ishmael. Some years ago...");
- let first_sentence = novel.split('.')
- .next()
- .expect("Could not find a '.'");
- let i = ImportantExcerpt { part: first_sentence };
- i.announce_and_return_part("hi");
- }
- struct ImportantExcerpt<'a> {
- part: &'a str,
- }
- impl<'a> ImportantExcerpt<'a> {
- fn announce_and_return_part<'b, 'c>(&'b self, announcement: &'c str) -> &'a str {
- println!("Attention please: {}", announcement);
- self.part
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement