From 6ec0c444f642630485ca18b3043191b67a6f8e8c Mon Sep 17 00:00:00 2001 From: Jokler Date: Sat, 12 May 2018 00:21:59 +0200 Subject: Factoids: Improve display of runtime errors in lua --- src/plugins/factoids/database.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins/factoids/database.rs') diff --git a/src/plugins/factoids/database.rs b/src/plugins/factoids/database.rs index 321931f..702834f 100644 --- a/src/plugins/factoids/database.rs +++ b/src/plugins/factoids/database.rs @@ -51,10 +51,10 @@ pub trait Database: Send + Sync { impl Database for HashMap<(String, i32), Factoid> { fn insert_factoid(&mut self, factoid: &NewFactoid) -> Result<(), FactoidsError> { let factoid = Factoid { - name: String::from(factoid.name), + name: factoid.name.to_owned(), idx: factoid.idx, - content: factoid.content.to_string(), - author: factoid.author.to_string(), + content: factoid.content.to_owned(), + author: factoid.author.to_owned(), created: factoid.created, }; @@ -66,13 +66,13 @@ impl Database for HashMap<(String, i32), Factoid> { } fn get_factoid(&self, name: &str, idx: i32) -> Result { - Ok(self.get(&(String::from(name), idx)) + Ok(self.get(&(name.to_owned(), idx)) .cloned() .ok_or(ErrorKind::NotFound)?) } fn delete_factoid(&mut self, name: &str, idx: i32) -> Result<(), FactoidsError> { - match self.remove(&(String::from(name), idx)) { + match self.remove(&(name.to_owned(), idx)) { Some(_) => Ok(()), None => Err(ErrorKind::NotFound)?, } -- cgit v1.2.3-70-g09d2