about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--indieauth/src/scopes.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/indieauth/src/scopes.rs b/indieauth/src/scopes.rs
index e1df371..02ee8dc 100644
--- a/indieauth/src/scopes.rs
+++ b/indieauth/src/scopes.rs
@@ -121,19 +121,20 @@ impl AsRef<[Scope]> for Scopes {
     }
 }
 
-// Explicit implementation of ToString because of specific requirements.
-#[allow(clippy::to_string_trait_impl)]
-impl ToString for Scopes {
-    fn to_string(&self) -> String {
-        self.0.iter()
-            .map(|s| s.as_ref())
-            .fold(String::new(), |a, s| if a.is_empty() {
-                s.to_string()
-            } else {
-                a + " " + s
-            })
+impl std::fmt::Display for Scopes {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        let mut iter = self.0.iter()
+            .peekable();
+        while let Some(scope) = iter.next() {
+            f.write_str(scope.as_ref())?;
+            if iter.peek().is_some() {
+                f.write_str(" ")?;
+            }
+        }
+        Ok(())
     }
 }
+
 impl FromStr for Scopes {
     type Err = std::convert::Infallible;