diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-22 20:27:30 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-22 20:27:30 +0200 |
commit | b33401043b512f2538079ea9ee618b09deffe0d5 (patch) | |
tree | 205b26ef4e168c2cb1b85867fb298aac0893e528 | |
parent | fix(storage/setters): Avoid writing a literal "NULL" string into the db (diff) | |
download | yt-b33401043b512f2538079ea9ee618b09deffe0d5.tar.gz yt-b33401043b512f2538079ea9ee618b09deffe0d5.zip |
refactor(storage/getters): Inline an Option re-creation with `map`
-rw-r--r-- | src/storage/video_database/getters.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/storage/video_database/getters.rs b/src/storage/video_database/getters.rs index b912276..176ebbb 100644 --- a/src/storage/video_database/getters.rs +++ b/src/storage/video_database/getters.rs @@ -122,11 +122,6 @@ pub async fn get_videos( let real_videos: Vec<Video> = videos .iter() .map(|base| -> Result<Video> { - let thumbnail_url = if let Some(url) = base.get("thumbnail_url") { - Some(Url::parse(url)?) - } else { - None - }; Ok(Video { cache_path: base .get::<Option<String>, &str>("cache_path") @@ -145,7 +140,10 @@ pub async fn get_videos( .clone(), publish_date: base.get("publish_date"), status: VideoStatus::from_db_integer(base.get("status")), - thumbnail_url, + thumbnail_url: base + .get::<Option<String>, &str>("thumbnail_url") + .as_ref() + .map(|url| Url::parse(url).expect("Parsing this as url should always work")), title: base.get::<String, &str>("title").to_owned(), url: Url::parse(base.get("url")).expect("Parsing this as url should always work"), priority: base.get("priority"), |