changeset 73:b493c1f99877

Disable full-featured example if feature full not enabled for automated testing
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 02 Apr 2022 13:49:42 -0700
parents 08db02ef7028
children e9ccc1702af0
files examples/full_featured.rs
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/examples/full_featured.rs	Sat Apr 02 13:46:13 2022 -0700
+++ b/examples/full_featured.rs	Sat Apr 02 13:49:42 2022 -0700
@@ -1,6 +1,6 @@
 use memoize::memoize;
-use std::time::{Instant, Duration};
 use std::thread;
+use std::time::{Duration, Instant};
 
 #[derive(Debug, Clone)]
 struct ComplexStruct {
@@ -9,6 +9,7 @@
     i: Instant,
 }
 
+#[cfg(feature = "full")]
 #[memoize(TimeToLive: Duration::from_secs(2), Capacity: 123)]
 fn hello(key: String) -> ComplexStruct {
     println!("hello: {}", key);
@@ -20,13 +21,16 @@
 }
 
 fn main() {
-    println!("result: {:?}", hello("ABC".to_string()));
-    println!("result: {:?}", hello("DEF".to_string()));
-    println!("result: {:?}", hello("ABC".to_string()));  //Same as first
-    thread::sleep(core::time::Duration::from_millis(2100));
-    println!("result: {:?}", hello("EFG".to_string()));
-    println!("result: {:?}", hello("ABC".to_string()));  //Refreshed
-    println!("result: {:?}", hello("EFG".to_string()));  //Same as first
-    println!("result: {:?}", hello("ABC".to_string()));  //Same as refreshed
-    println!("result: {:?}", memoized_original_hello("ABC".to_string()));
+    #[cfg(feature = "full")]
+    {
+        println!("result: {:?}", hello("ABC".to_string()));
+        println!("result: {:?}", hello("DEF".to_string()));
+        println!("result: {:?}", hello("ABC".to_string())); //Same as first
+        thread::sleep(core::time::Duration::from_millis(2100));
+        println!("result: {:?}", hello("EFG".to_string()));
+        println!("result: {:?}", hello("ABC".to_string())); //Refreshed
+        println!("result: {:?}", hello("EFG".to_string())); //Same as first
+        println!("result: {:?}", hello("ABC".to_string())); //Same as refreshed
+        println!("result: {:?}", memoized_original_hello("ABC".to_string()));
+    }
 }