Skip to content

Commit 77185b2

Browse files
committed
Rm dead code
1 parent cafe7a8 commit 77185b2

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

examples/axum-example/src/routes/form.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub struct SubscribeResponse {
2121
pub is_subscribed: bool,
2222
}
2323

24-
#[allow(dead_code)]
2524
#[derive(Deserialize, Schema)]
2625
pub struct ContactFormRequest {
2726
pub name: String,
@@ -55,7 +54,7 @@ pub async fn subscribe(Form(input): Form<SubscribeRequest>) -> Json<SubscribeRes
5554
pub async fn contact(Form(input): Form<ContactFormRequest>) -> Json<ContactFormResponse> {
5655
Json(ContactFormResponse {
5756
success: true,
58-
ticket_id: format!("TICKET-{}", input.name.len() + input.message.len()),
57+
ticket_id: format!("TICKET-{}-{}", input.name.len() + input.message.len(), input.email.len() + input.subject.as_deref().map_or(0, str::len)),
5958
})
6059
}
6160

examples/axum-example/src/routes/users.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,12 @@ pub async fn create_user_with_meta(
130130
pub struct SkipResponse {
131131
pub name: String,
132132
#[serde(skip)]
133-
#[allow(dead_code)]
134133
pub email: String,
135134

136135
#[serde(skip, skip_serializing_if = "Option::is_none")]
137-
#[allow(dead_code)]
138136
pub email2: Option<String>,
139137

140138
#[serde(rename = "email3", skip)]
141-
#[allow(dead_code)]
142139
pub email3: Option<String>,
143140

144141
#[serde(rename = "email4", skip_serializing_if = "Option::is_none")]
@@ -151,7 +148,6 @@ pub struct SkipResponse {
151148
pub email6: String,
152149

153150
#[serde(rename = "email7", skip)]
154-
#[allow(dead_code)]
155151
pub email7: String,
156152

157153
#[serde(rename = "num", default)]
@@ -176,7 +172,7 @@ fn default_value() -> String {
176172

177173
#[vespera::route(get, path = "/skip-response")]
178174
pub async fn skip_response() -> Json<SkipResponse> {
179-
Json(SkipResponse {
175+
let response = SkipResponse {
180176
name: "John Doe".to_string(),
181177
email: "john.doe@example.com".to_string(),
182178
email2: Some("john.doe2@example.com".to_string()),
@@ -210,5 +206,8 @@ pub async fn skip_response() -> Json<SkipResponse> {
210206
name: "John Doe".to_string(),
211207
},
212208
)])),
213-
})
209+
};
210+
// Read skip fields to validate they're populated correctly
211+
let _ = (&response.email, &response.email2, &response.email3, &response.email7);
212+
Json(response)
214213
}

0 commit comments

Comments
 (0)