Skip to content

Commit 103f23c

Browse files
committed
controllers::user::me: Use json! macro to simplify JSON serialization code
1 parent 0424d29 commit 103f23c

File tree

1 file changed

+5
-14
lines changed
  • src/controllers/user

1 file changed

+5
-14
lines changed

src/controllers/user/me.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,12 @@ pub fn updates(req: &mut dyn RequestExt) -> EndpointResult {
8383
.map(|(version, crate_name, published_by, actions)| {
8484
EncodableVersion::from(version, &crate_name, published_by, actions)
8585
})
86-
.collect();
86+
.collect::<Vec<_>>();
8787

88-
#[derive(Serialize)]
89-
struct R {
90-
versions: Vec<EncodableVersion>,
91-
meta: Meta,
92-
}
93-
#[derive(Serialize)]
94-
struct Meta {
95-
more: bool,
96-
}
97-
Ok(req.json(&R {
98-
versions,
99-
meta: Meta { more },
100-
}))
88+
Ok(req.json(&json!({
89+
"versions": versions,
90+
"meta": { "more": more },
91+
})))
10192
}
10293

10394
/// Handles the `PUT /users/:user_id` route.

0 commit comments

Comments
 (0)