Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement