From 654fabf7f3889d2a108b464072e84adc051fcaf5 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sun, 10 Oct 2021 21:05:14 +0200 Subject: Update rust version --- src/database.rs | 6 +++--- src/errors.rs | 5 ----- src/main.rs | 3 --- src/spotify.rs | 4 +++- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/database.rs b/src/database.rs index e7b6f7f..bf986c7 100644 --- a/src/database.rs +++ b/src/database.rs @@ -61,14 +61,14 @@ pub async fn insert_track(user_id: i32, track: FullTrack, weight: i32) -> Result println!("{:#?}", track); return Err("failed to load get track information".into()); } - print!(" {} ", track.id.clone()?); + print!(" {} ", track.id.clone().unwrap()); client .execute( "INSERT INTO track (track_code, name, artist, popularity) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING", &[ - &(track.id.clone()?), + &(track.id.clone().unwrap()), &track.name, &track.artists[0].name, &(track.popularity as i32), @@ -78,7 +78,7 @@ pub async fn insert_track(user_id: i32, track: FullTrack, weight: i32) -> Result let track_id: i32 = client .query( "SELECT track_id FROM track where track_code = $1;", - &[&(track.id?)], + &[&(track.id.unwrap())], ) .await?[0] .get(0); diff --git a/src/errors.rs b/src/errors.rs index 51ac8fd..4217939 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -44,11 +44,6 @@ impl<'a> From>> for Error { Error::Misc(format!("failed to lock the client mutex: {:?}", error)) } } -impl<'a> From for Error { - fn from(error: std::option::NoneError) -> Self { - Error::Misc(format!("tried to unwrap none at: {:?}", error)) - } -} impl<'a> Responder<'a, 'a> for Error { fn respond_to(self, _: &Request) -> response::Result<'a> { let response = match self { diff --git a/src/main.rs b/src/main.rs index 0ff4827..b297f14 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,3 @@ -#![feature(proc_macro_hygiene, decl_macro)] -#![feature(try_trait)] - #[macro_use] extern crate rocket; #[macro_use] diff --git a/src/spotify.rs b/src/spotify.rs index 04a82bc..5d2dc8c 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -116,7 +116,9 @@ fn generate_random_uuid(length: usize) -> String { pub async fn auth_user(name: &str, code: &str) -> Result<(String, Spotify), Error> { let (user, mut spotify) = { let mut guard = (*CACHE).lock()?; - guard.remove(name)? + guard + .remove(name) + .ok_or(Error::Misc("failed to remove user from waitlist".into()))? }; println!("auth: {:?} url: {}", name, code); spotify.request_user_token(code).await?; -- cgit v1.2.3