Skip to main content

max / makenotwork

Fix clippy gate: prefer contains/as_ref, drop needless Ok(?) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-06-17 21:16 UTC
Commit: f8ea7a18e80e9c1fc1eedd57cea376b49a9f9c4a
Parent: 72ab17f
2 files changed, +11 insertions, -11 deletions
@@ -55,7 +55,7 @@ impl UrlPolicy {
55 55
56 56 fn is_internal_host(&self, host: &str) -> bool {
57 57 let host = host.to_ascii_lowercase();
58 - self.hosts.iter().any(|h| *h == host)
58 + self.hosts.contains(&host)
59 59 }
60 60 }
61 61
@@ -96,7 +96,7 @@ pub async fn user_editor(
96 96 AuthUser(user): AuthUser,
97 97 session: Session,
98 98 ) -> Result<Response> {
99 - let target = user_target(&state, user.id, &user.username.to_string()).await?;
99 + let target = user_target(&state, user.id, user.username.as_ref()).await?;
100 100 render_editor(&state, &session, target).await
101 101 }
102 102
@@ -105,7 +105,7 @@ pub async fn user_save(
105 105 AuthUser(user): AuthUser,
106 106 Form(form): Form<CustomPageForm>,
107 107 ) -> Result<Response> {
108 - let target = user_target(&state, user.id, &user.username.to_string()).await?;
108 + let target = user_target(&state, user.id, user.username.as_ref()).await?;
109 109 save(&state, target, form).await
110 110 }
111 111
@@ -114,12 +114,12 @@ pub async fn user_autosave(
114 114 AuthUser(user): AuthUser,
115 115 Form(form): Form<CustomPageForm>,
116 116 ) -> Result<Response> {
117 - let target = user_target(&state, user.id, &user.username.to_string()).await?;
117 + let target = user_target(&state, user.id, user.username.as_ref()).await?;
118 118 autosave(&state, target, form).await
119 119 }
120 120
121 121 pub async fn user_reset(State(state): State<AppState>, AuthUser(user): AuthUser) -> Result<Response> {
122 - let target = user_target(&state, user.id, &user.username.to_string()).await?;
122 + let target = user_target(&state, user.id, user.username.as_ref()).await?;
123 123 reset(&state, target).await
124 124 }
125 125
@@ -129,7 +129,7 @@ pub async fn project_editor(
129 129 session: Session,
130 130 Path(slug): Path<String>,
131 131 ) -> Result<Response> {
132 - let target = project_target(&state, user.id, &user.username.to_string(), &slug).await?;
132 + let target = project_target(&state, user.id, user.username.as_ref(), &slug).await?;
133 133 render_editor(&state, &session, target).await
134 134 }
135 135
@@ -139,7 +139,7 @@ pub async fn project_save(
139 139 Path(slug): Path<String>,
140 140 Form(form): Form<CustomPageForm>,
141 141 ) -> Result<Response> {
142 - let target = project_target(&state, user.id, &user.username.to_string(), &slug).await?;
142 + let target = project_target(&state, user.id, user.username.as_ref(), &slug).await?;
143 143 save(&state, target, form).await
144 144 }
145 145
@@ -149,7 +149,7 @@ pub async fn project_autosave(
149 149 Path(slug): Path<String>,
150 150 Form(form): Form<CustomPageForm>,
151 151 ) -> Result<Response> {
152 - let target = project_target(&state, user.id, &user.username.to_string(), &slug).await?;
152 + let target = project_target(&state, user.id, user.username.as_ref(), &slug).await?;
153 153 autosave(&state, target, form).await
154 154 }
155 155
@@ -158,7 +158,7 @@ pub async fn project_reset(
158 158 AuthUser(user): AuthUser,
159 159 Path(slug): Path<String>,
160 160 ) -> Result<Response> {
161 - let target = project_target(&state, user.id, &user.username.to_string(), &slug).await?;
161 + let target = project_target(&state, user.id, user.username.as_ref(), &slug).await?;
162 162 reset(&state, target).await
163 163 }
164 164
@@ -223,7 +223,7 @@ async fn render_editor(state: &AppState, session: &Session, target: Target) -> R
223 223 let preview_url = format!("{}/preview/{}", user_pages_origin(state), draft.id);
224 224 let csrf_token = get_csrf_token(session).await;
225 225
226 - Ok(EditorTemplate {
226 + EditorTemplate {
227 227 csrf_token,
228 228 heading: target.heading,
229 229 html_value: draft.custom_html,
@@ -236,7 +236,7 @@ async fn render_editor(state: &AppState, session: &Session, target: Target) -> R
236 236 }
237 237 .render()
238 238 .map(|h| Html(h).into_response())
239 - .map_err(|_| AppError::Internal(anyhow::anyhow!("template render failed")))?)
239 + .map_err(|_| AppError::Internal(anyhow::anyhow!("template render failed")))
240 240 }
241 241
242 242 async fn save(state: &AppState, target: Target, form: CustomPageForm) -> Result<Response> {