Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unused)]
- struct Foo {
- text1: Option<String>,
- text2: String,
- }
- impl Foo {
- pub fn set_text(&mut self) {
- if let Some(ref mut t) = self.text1 {
- t.pop();
- self.set_text2();
- }
- }
- fn set_text2(&mut self) {
- self.text2.pop();
- println!("{}", self.text2);
- }
- }
- fn main() {
- let mut foo = Foo {
- text1: Some("hello, world!".to_string()),
- text2: "I am 谭越".to_string(),
- };
- foo.set_text();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement