From 43e24254b8dab070ff834c5b3d808a5c916766b7 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Fri, 2 Aug 2024 21:40:15 -0700 Subject: [PATCH] Simplified renaming code --- .scripts/src/retrieve_toots.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.scripts/src/retrieve_toots.rs b/.scripts/src/retrieve_toots.rs index 21680af..41a8e2b 100644 --- a/.scripts/src/retrieve_toots.rs +++ b/.scripts/src/retrieve_toots.rs @@ -16,22 +16,15 @@ fn reformat_toot(x: &mut serde_json::Value) -> Result<(), String> { .ok_or_else(|| "JSON not an object".to_string())?; // URL -> Syndication - let toot_url: serde_json::Value = toot - .get_mut("url") - .ok_or_else(|| "Missing URL".to_string())? - .to_owned(); toot.remove("uri"); - toot.remove("url"); - toot.insert("syndication".to_string(), toot_url.to_owned()); + let toot_url = toot.remove("url") + .ok_or_else(|| "Missing URL".to_string())?; + toot.insert("syndication".to_string(), toot_url); // Created At -> Date - let toot_date: serde_json::Value = toot - .get_mut("created_at") - .ok_or_else(|| "Missing created_at".to_string())? - .to_owned(); - // Note: Already checked whether created_at exists - toot.remove("created_at"); - toot.insert("date".to_string(), toot_date.to_owned()); + let toot_date = toot.remove("created_at") + .ok_or_else(|| "Missing created_at".to_string())?; + toot.insert("date".to_string(), toot_date); // Strip out highly dynamic account information let account: &mut tera::Map = toot