]> piware.de Git - learn-rust.git/blobdiff - concepts/src/main.rs
concepts: Add Post.reject() transition
[learn-rust.git] / concepts / src / main.rs
index 94bdb960aa7e79b80d4ad22f082ab2822e6c1fbc..3e9bbbd0cd042234615d20dd563baf6278258464 100644 (file)
@@ -247,6 +247,25 @@ 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.reject();
+    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 +275,5 @@ fn main() {
     test_closures();
     test_iterators();
     test_threads();
+    test_dyn_traits();
 }