style(list): 简化多行表达式为单行
Some checks failed
CI / check (push) Failing after 13m53s
CI / build (push) Has been skipped

This commit is contained in:
xfy 2026-06-15 14:15:11 +08:00
parent 94319d3411
commit 1cc4bc5aeb

View File

@ -31,10 +31,7 @@ const MAX_PAGE: i32 = 10_000;
/// ///
/// 注意:返回值必须同时用于缓存键与 SQL 查询,避免同一逻辑页落入不同缓存条目。 /// 注意:返回值必须同时用于缓存键与 SQL 查询,避免同一逻辑页落入不同缓存条目。
fn clamp_pagination(page: i32, per_page: i32) -> (i32, i32) { fn clamp_pagination(page: i32, per_page: i32) -> (i32, i32) {
( (page.clamp(1, MAX_PAGE), per_page.clamp(1, MAX_PER_PAGE))
page.clamp(1, MAX_PAGE),
per_page.clamp(1, MAX_PER_PAGE),
)
} }
/// 获取已发布文章分页列表。 /// 获取已发布文章分页列表。
@ -269,9 +266,6 @@ mod tests {
#[test] #[test]
fn clamp_pagination_max_per_page_boundary() { fn clamp_pagination_max_per_page_boundary() {
assert_eq!(clamp_pagination(1, MAX_PER_PAGE), (1, MAX_PER_PAGE)); assert_eq!(clamp_pagination(1, MAX_PER_PAGE), (1, MAX_PER_PAGE));
assert_eq!( assert_eq!(clamp_pagination(1, MAX_PER_PAGE - 1), (1, MAX_PER_PAGE - 1));
clamp_pagination(1, MAX_PER_PAGE - 1),
(1, MAX_PER_PAGE - 1)
);
} }
} }