Skip to content

Commit 473cb87

Browse files
committed
[clippy] fixes
1 parent 98b3ac3 commit 473cb87

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

sweep-lib/src/scorer.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,14 @@ impl<D: AsRef<[u8]>> Positions<D> {
755755
Self { data }
756756
}
757757

758+
pub fn len(&self) -> usize {
759+
self.data.as_ref().len() << POISTIONS_SHIFT
760+
}
761+
762+
pub fn is_empty(&self) -> bool {
763+
self.data.as_ref().is_empty()
764+
}
765+
758766
/// check if index is present
759767
pub fn get(&self, index: usize) -> bool {
760768
let (index, mask) = positions_offset(index);
@@ -774,9 +782,9 @@ impl<D: AsRef<[u8]>> Positions<D> {
774782

775783
impl Positions<Vec<u8>> {
776784
pub fn new_owned(size: usize) -> Self {
777-
let mut data = Vec::new();
778-
data.resize(positions_data_size(size), 0);
779-
Positions { data }
785+
Positions {
786+
data: vec![0; positions_data_size(size)],
787+
}
780788
}
781789
}
782790

sweep-lib/src/sweep.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -2147,8 +2147,8 @@ where
21472147
let window_event = match request {
21482148
Terminate => return Ok(TerminalAction::Quit(())),
21492149
WindowSwitch { window, created } => {
2150-
let uid = window.as_ref().either(|win| win.uid(), |uid| &uid);
2151-
if window_stack.window_position(&uid).is_some() {
2150+
let uid = window.as_ref().either(|win| win.uid(), |uid| uid);
2151+
if window_stack.window_position(uid).is_some() {
21522152
_ = created.send(false);
21532153
WindowAction::Switch {
21542154
uid: uid.clone(),
@@ -2157,22 +2157,19 @@ where
21572157
}
21582158
} else {
21592159
_ = created.send(true);
2160-
let window = window.either(
2161-
|win| Ok::<_, Error>(win),
2162-
|uid| {
2163-
let win = Box::new(SweepWindow::new_from_options(
2164-
SweepOptions {
2165-
window_uid: uid.clone(),
2166-
..options.clone()
2167-
},
2168-
haystack_context.clone(),
2169-
term.waker(),
2170-
Some(window_dispatch.create(uid)?),
2171-
event_handler_default.clone(),
2172-
));
2173-
Ok(win)
2174-
},
2175-
)?;
2160+
let window = window.either(Ok::<_, Error>, |uid| {
2161+
let win = Box::new(SweepWindow::new_from_options(
2162+
SweepOptions {
2163+
window_uid: uid.clone(),
2164+
..options.clone()
2165+
},
2166+
haystack_context.clone(),
2167+
term.waker(),
2168+
Some(window_dispatch.create(uid)?),
2169+
event_handler_default.clone(),
2170+
));
2171+
Ok(win)
2172+
})?;
21762173
WindowAction::Open { window }
21772174
}
21782175
}

0 commit comments

Comments
 (0)