style(list): 简化多行表达式为单行
This commit is contained in:
parent
94319d3411
commit
1cc4bc5aeb
@ -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)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user