Skip to content

Commit c735519

Browse files
committed
Fixed some clippy warnings in libpaperback.
1 parent 30a58c2 commit c735519

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

lib/src/bridge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ fn session_get_status_info(session: &DocumentSession, position: i64) -> ffi::Ffi
11271127
}
11281128
}
11291129

1130-
fn session_stats(session: &DocumentSession) -> ffi::FfiDocumentStats {
1130+
const fn session_stats(session: &DocumentSession) -> ffi::FfiDocumentStats {
11311131
document_stats_to_ffi(session.stats())
11321132
}
11331133

lib/src/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ where
170170
if ext.is_empty() {
171171
continue;
172172
}
173-
if !first {
174-
result.push(';');
175-
} else {
173+
if first {
176174
first = false;
175+
} else {
176+
result.push(';');
177177
}
178178
result.push_str("*.");
179179
result.push_str(ext);

lib/src/session.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,14 @@ pub struct LinkActivationResult {
8989
pub url: String,
9090
}
9191

92-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
92+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
9393
pub enum LinkAction {
9494
Internal,
9595
External,
96+
#[default]
9697
NotFound,
9798
}
9899

99-
impl Default for LinkAction {
100-
fn default() -> Self {
101-
Self::NotFound
102-
}
103-
}
104-
105100
impl LinkActivationResult {
106101
const fn not_found() -> Self {
107102
Self { found: false, action: LinkAction::NotFound, offset: 0, url: String::new() }
@@ -657,8 +652,7 @@ impl DocumentSession {
657652
}
658653
self.handle
659654
.get_marker_position_by_index(MarkerType::PageBreak, page_index)
660-
.map(|offset| i64::try_from(offset).unwrap_or(-1))
661-
.unwrap_or(-1)
655+
.map_or(-1, |offset| i64::try_from(offset).unwrap_or(-1))
662656
}
663657

664658
/// Returns the text between two positions (start inclusive, end exclusive).

0 commit comments

Comments
 (0)