X-Git-Url: https://piware.de/gitweb/?p=learn-rust.git;a=blobdiff_plain;f=concepts%2Fsrc%2Fmain.rs;fp=concepts%2Fsrc%2Fmain.rs;h=f9eafe95978b7bb802c7f1b8ffd3088cf2c19792;hp=94bdb960aa7e79b80d4ad22f082ab2822e6c1fbc;hb=c182c6166ae3971320daaeadba3ea718124303e7;hpb=89ba5f70f2de2cf038b2abb701a3d257c6b965d8 diff --git a/concepts/src/main.rs b/concepts/src/main.rs index 94bdb96..f9eafe9 100644 --- a/concepts/src/main.rs +++ b/concepts/src/main.rs @@ -247,6 +247,19 @@ fn test_threads() { println!("counter: {}", *counter.lock().unwrap()); } +fn test_dyn_traits() { + let text = "I ate a salad for lunch today"; + let mut post = Post::new(); + post.add_text(text); + assert_eq!("", post.content()); + + post.request_review(); + assert_eq!("", post.content()); + + post.approve(); + assert_eq!(text, post.content()); +} + fn main() { test_strings(); test_vectors(); @@ -256,4 +269,5 @@ fn main() { test_closures(); test_iterators(); test_threads(); + test_dyn_traits(); }