From 3fd89e6b48a84c99fedce3d8152914b2f2a31130 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sat, 16 Jan 2021 01:05:42 +0900 Subject: [PATCH] Remove unnecessary wraps --- plume-models/src/blogs.rs | 16 ++++++++-------- plume-models/src/safe_string.rs | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index 0bea73d4..8df4a9dc 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -216,16 +216,16 @@ impl Blog { pub fn outbox(&self, conn: &Connection) -> Result> { let mut coll = OrderedCollection::default(); - coll.collection_props.items = serde_json::to_value(self.get_activities(conn)?)?; + coll.collection_props.items = serde_json::to_value(self.get_activities(conn))?; coll.collection_props - .set_total_items_u64(self.get_activities(conn)?.len() as u64)?; + .set_total_items_u64(self.get_activities(conn).len() as u64)?; coll.collection_props .set_first_link(Id::new(ap_url(&format!("{}?page=1", &self.outbox_url))))?; coll.collection_props .set_last_link(Id::new(ap_url(&format!( "{}?page={}", &self.outbox_url, - (self.get_activities(conn)?.len() as u64 + ITEMS_PER_PAGE as u64 - 1) as u64 + (self.get_activities(conn).len() as u64 + ITEMS_PER_PAGE as u64 - 1) as u64 / ITEMS_PER_PAGE as u64 ))))?; Ok(ActivityStream::new(coll)) @@ -236,7 +236,7 @@ impl Blog { (min, max): (i32, i32), ) -> Result> { let mut coll = OrderedCollectionPage::default(); - let acts = self.get_activity_page(&conn, (min, max))?; + let acts = self.get_activity_page(&conn, (min, max)); //This still doesn't do anything because the outbox //doesn't do anything yet coll.collection_page_props.set_next_link(Id::new(&format!( @@ -252,15 +252,15 @@ impl Blog { coll.collection_props.items = serde_json::to_value(acts)?; Ok(ActivityStream::new(coll)) } - fn get_activities(&self, _conn: &Connection) -> Result> { - Ok(vec![]) + fn get_activities(&self, _conn: &Connection) -> Vec { + vec![] } fn get_activity_page( &self, _conn: &Connection, (_min, _max): (i32, i32), - ) -> Result> { - Ok(vec![]) + ) -> Vec { + vec![] } pub fn get_keypair(&self) -> Result> { diff --git a/plume-models/src/safe_string.rs b/plume-models/src/safe_string.rs index 510cfb3e..086395f4 100644 --- a/plume-models/src/safe_string.rs +++ b/plume-models/src/safe_string.rs @@ -81,6 +81,7 @@ lazy_static! { }; } +#[allow(clippy::unnecessary_wraps)] fn url_add_prefix(url: &str) -> Option> { if url.starts_with('#') && !url.starts_with("#postcontent-") { //if start with an #