style(clippy): enforce clippy use_self lint

Clippy's `use_self` line ensures that `Self` is used instead of the real
name whenever possible. This makes searching easier and cleans up the
code a bit.
This commit is contained in:
Thomas Frans
2023-09-27 21:53:13 +02:00
committed by Henrik Friedrichsen
parent 01e01b59e4
commit fe8f8e78ee
25 changed files with 170 additions and 172 deletions

View File

@@ -25,8 +25,8 @@ impl fmt::Display for SpotifyUrl {
}
impl SpotifyUrl {
pub fn new(id: &str, uri_type: UriType) -> SpotifyUrl {
SpotifyUrl {
pub fn new(id: &str, uri_type: UriType) -> Self {
Self {
id: id.to_string(),
uri_type,
}
@@ -39,7 +39,7 @@ impl SpotifyUrl {
/// assert_eq!(result.id, "4uLU6hMCjMI75M1A2tKUQC");
/// assert_eq!(result.uri_type, URIType::Track);
/// ```
pub fn from_url<S: AsRef<str>>(s: S) -> Option<SpotifyUrl> {
pub fn from_url<S: AsRef<str>>(s: S) -> Option<Self> {
let url = Url::parse(s.as_ref()).ok()?;
if url.host() != Some(Host::Domain("open.spotify.com")) {
return None;
@@ -71,7 +71,7 @@ impl SpotifyUrl {
let id = path_segments.next()?;
Some(SpotifyUrl::new(id, uri_type))
Some(Self::new(id, uri_type))
}
}