X-Git-Url: https://piware.de/gitweb/?p=learn-rust.git;a=blobdiff_plain;f=concepts%2Fsrc%2Fmain.rs;h=4b6df6447be9930e5773202f24601cd817722eb8;hp=20826216bbd4c0ec5a0e8e3cec408f507b28140b;hb=d6fbfabfaf434ae365854f0587547cff3ca78dae;hpb=1962a5412d16f34c738e9f81bb5271da043a7505 diff --git a/concepts/src/main.rs b/concepts/src/main.rs index 2082621..4b6df64 100644 --- a/concepts/src/main.rs +++ b/concepts/src/main.rs @@ -272,6 +272,17 @@ fn test_dyn_traits() { assert_eq!(text, post.content()); } +fn test_state_types() { + let mut post = TPost::new(); + post.add_text("I ate a salad for lunch"); + let post = post.request_review(); + let mut post = post.reject(); + post.add_text(" today"); + let post = post.request_review(); + let post = post.approve(); + assert_eq!(post.content(), "I ate a salad for lunch today"); +} + fn main() { test_strings(); test_vectors(); @@ -282,4 +293,5 @@ fn main() { test_iterators(); test_threads(); test_dyn_traits(); + test_state_types(); }