summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-08-29 00:40:28 -0400
committerBen Morrison <ben@gbmor.dev>2019-08-29 00:40:28 -0400
commit25323a54aed498f03fca1bd99935db004d4217fd (patch)
treeb012059daa589bcd46fea355a3f1ba32cbf385a0 /src
parent6dd17c5a5de31725d7a1ed7f636b001ea8a23a51 (diff)
downloadclinte-25323a54aed498f03fca1bd99935db004d4217fd.tar.gz
limit number of displayed posts to 30 v0.1.0
Diffstat (limited to 'src')
-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) {
y/commit/src/profanity.h?id=346ed2a8e861457effcba6c7c7cc76f660ece40b'>346ed2a8 ^
310d712d ^
9f00ef14 ^
8e90f7a4 ^

02224ea7 ^
a574f7ff ^


bfc9e9a7 ^
c3b0e804 ^
28b17238 ^
e45e6c46 ^
4493f555 ^



be2fb1c8 ^

54e591fe ^
181669a8 ^



645d1b74 ^


81f92929 ^
49676e3f ^

bd3f1d15 ^

b3e1d473 ^

118d97cd ^

28b17238 ^
5d9c7ffd ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70