summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-08-30 18:09:15 -0400
committerBen Morrison <ben@gbmor.dev>2019-08-30 18:09:15 -0400
commit809b28722d55632a1ee5ed081084a74c9a011ef9 (patch)
tree6bde8c55a868b9fd38d16fb103eb70c123f523cb
parente276b9bfaf5795ed9e5ec4896fc9d2678ff8e51c (diff)
downloadclinte-809b28722d55632a1ee5ed081084a74c9a011ef9.tar.gz
moved str_to_utf8 on post, rather than display v0.3.1
-rw-r--r--src/main.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 6eb06fa..9541176 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -70,8 +70,6 @@ fn list_matches(db: &db::Conn) {
             let title: String = row.get(1)?;
             let author: String = row.get(2)?;
             let body: String = row.get(3)?;
-            let title = str_to_utf8(&title);
-            let body = str_to_utf8(&body);
             Ok(db::Post {
                 id,
                 title,
@@ -108,7 +106,7 @@ fn post(db: &db::Conn) {
     println!("Title of the new post: ");
     let mut title = String::new();
     io::stdin().read_line(&mut title).unwrap();
-    let title = title.trim();
+    let title = str_to_utf8(title.trim());
     let title = if title.len() > 30 {
         &title[..30]
     } else {
@@ -119,7 +117,7 @@ fn post(db: &db::Conn) {
     println!("Body of the new post: ");
     let mut body = String::new();
     io::stdin().read_line(&mut body).unwrap();
-    let body = body.trim();
+    let body = str_to_utf8(body.trim());
     let body = if body.len() > 500 {
         &body[..500]
     } else {