From 809b28722d55632a1ee5ed081084a74c9a011ef9 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Fri, 30 Aug 2019 18:09:15 -0400 Subject: moved str_to_utf8 on post, rather than display --- src/main.rs | 6 ++---- 1 file 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 { -- cgit 1.4.1-2-gfad0