SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(unused)]
  2. struct Foo {
  3.     text1: Option<String>,
  4.     text2: String,
  5. }
  6.  
  7. impl Foo {
  8.     pub fn set_text(&mut self) {
  9.         if let Some(ref mut t) = self.text1 {
  10.             t.pop();
  11.             self.set_text2();
  12.         }    
  13.     }
  14.    
  15.     fn set_text2(&mut self) {
  16.         self.text2.pop();
  17.         println!("{}", self.text2);
  18.     }
  19. }
  20. fn main() {
  21.     let mut foo = Foo {
  22.         text1: Some("hello, world!".to_string()),
  23.         text2: "I am 谭越".to_string(),
  24.     };
  25.  
  26.     foo.set_text();
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top