@@ -203,18 +203,18 @@ impl SpotifyUri {
203203 /// `spotify:user:{user}:{type}:{id}`.
204204 ///
205205 /// [Spotify URI]: https://developer.spotify.com/documentation/web-api/concepts/spotify-uris-ids
206- pub fn to_uri ( & self ) -> Result < String , Error > {
206+ pub fn to_uri ( & self ) -> String {
207207 let item_type = self . item_type ( ) ;
208- let name = self . to_id ( ) ;
209208
210209 if let SpotifyUri :: Playlist {
211210 id,
212211 user : Some ( user) ,
213212 } = self
214213 {
215- Ok ( format ! ( "spotify:user:{user}:{item_type}:{id}" ) )
214+ format ! ( "spotify:user:{user}:{item_type}:{id}" )
216215 } else {
217- Ok ( format ! ( "spotify:{item_type}:{name}" ) )
216+ let name = self . to_id ( ) ;
217+ format ! ( "spotify:{item_type}:{name}" )
218218 }
219219 }
220220
@@ -231,15 +231,13 @@ impl SpotifyUri {
231231
232232impl fmt:: Debug for SpotifyUri {
233233 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
234- f. debug_tuple ( "SpotifyUri" )
235- . field ( & self . to_uri ( ) . unwrap_or_else ( |_| "invalid uri" . into ( ) ) )
236- . finish ( )
234+ f. debug_tuple ( "SpotifyUri" ) . field ( & self . to_uri ( ) ) . finish ( )
237235 }
238236}
239237
240238impl fmt:: Display for SpotifyUri {
241239 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
242- f. write_str ( & self . to_uri ( ) . unwrap_or_else ( |_| "invalid uri" . into ( ) ) )
240+ f. write_str ( & self . to_uri ( ) )
243241 }
244242}
245243
@@ -597,7 +595,7 @@ mod tests {
597595 #[ test]
598596 fn to_uri ( ) {
599597 for c in & CONV_VALID {
600- assert_eq ! ( c. parsed. to_uri( ) . unwrap ( ) , c. uri) ;
598+ assert_eq ! ( c. parsed. to_uri( ) , c. uri) ;
601599 }
602600 }
603601
@@ -608,6 +606,6 @@ mod tests {
608606 let actual =
609607 SpotifyUri :: from_uri ( "spotify:user:spotify:playlist:37i9dQZF1DWSw8liJZcPOI" ) . unwrap ( ) ;
610608
611- assert_eq ! ( actual. to_uri( ) . unwrap ( ) , string) ;
609+ assert_eq ! ( actual. to_uri( ) , string) ;
612610 }
613611}
0 commit comments