summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/main.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 92a8613..65a6022 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -65,15 +65,23 @@ fn list_matches(db: &db::Conn) {
         })
         .unwrap();
 
+    let mut postvec = Vec::new();
     out.for_each(|row| {
         if let Ok(post) = row {
-            println!(
-                "{}. {} -> by {}\n{}",
+            postvec.push(format!(
+                "{}. {} -> by {}\n{}\n\n",
                 post.id, post.title, post.author, post.body
-            );
-            println!();
+            ));
         }
     });
+
+    for (i, e) in postvec.iter().enumerate() {
+        if postvec.len() >= 30 && i >= postvec.len() - 31 {
+            print!("{}", e);
+        } else if postvec.len() < 30 {
+            print!("{}", e);
+        }
+    }
 }
 
 fn post(db: &db::Conn) {
n89' href='#n89'>89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143