Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fmt;
- fn main() {
- let hell = abc_123(); //"abc 123";
- let say = TestMsg { msg: "hi there" };
- let _say:TestMsg;
- let _say_again = say.clone();
- let _psay: &TestMsg = &say;
- println!("var0. {}", hell);
- println!("var1. {}", say);
- println!("var1a. {}", (*_psay).msg);
- println!("var2. {:?}", say);
- }
- #[derive(Debug,Clone)]
- struct TestMsg<'a> {
- msg: &'a str,
- }
- fn abc_123 () -> & 'static str {
- "abc 123"
- }
- impl<'a> fmt::Display for TestMsg<'a> {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- write!(f, "test1 {}", self.msg)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement