Skip to content

Commit

Permalink
refactor: fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
murlakatamenka committed Mar 13, 2024
1 parent 5e3eb37 commit 22d36a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
34 changes: 14 additions & 20 deletions libwayshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,30 +389,25 @@ impl WayshotConnection {

pub fn capture_frame_copies(
&self,
output_capture_regions: &Vec<(OutputInfo, Option<EmbeddedRegion>)>,
output_capture_regions: &[(OutputInfo, Option<EmbeddedRegion>)],
cursor_overlay: bool,
) -> Result<Vec<(FrameCopy, FrameGuard, OutputInfo)>> {
let frame_copies = thread::scope(|scope| -> Result<_> {
let join_handles = output_capture_regions
.into_iter()
.iter()
.map(|(output_info, capture_region)| {
scope.spawn(move || {
self.capture_frame_copy(
cursor_overlay,
&output_info,
capture_region.clone(),
)
.map(|(frame_copy, frame_guard)| {
(frame_copy, frame_guard, output_info.clone())
})
self.capture_frame_copy(cursor_overlay, output_info, *capture_region)
.map(|(frame_copy, frame_guard)| {
(frame_copy, frame_guard, output_info.clone())
})
})
})
.collect::<Vec<_>>();

join_handles
.into_iter()
.map(|join_handle| join_handle.join())
.flatten()
.flat_map(|join_handle| join_handle.join())
.collect::<Result<_>>()
})?;

Expand Down Expand Up @@ -510,12 +505,12 @@ impl WayshotConnection {
let outputs_capture_regions: &Vec<(OutputInfo, Option<EmbeddedRegion>)> =
&match region_capturer {
RegionCapturer::Outputs(ref outputs) => outputs
.into_iter()
.iter()
.map(|output_info| (output_info.clone(), None))
.collect(),
RegionCapturer::Region(capture_region) => self
.get_all_outputs()
.into_iter()
.iter()
.filter_map(|output_info| {
tracing::span!(
tracing::Level::DEBUG,
Expand All @@ -542,7 +537,7 @@ impl WayshotConnection {
.collect(),
RegionCapturer::Freeze(_) => self
.get_all_outputs()
.into_iter()
.iter()
.map(|output_info| (output_info.clone(), None))
.collect(),
};
Expand All @@ -566,7 +561,7 @@ impl WayshotConnection {
.map(|(output_info, _)| output_info.scale())
.fold(1.0, f64::max);

tracing::Span::current().record("max_scale", &max_scale);
tracing::Span::current().record("max_scale", max_scale);

let rotate_join_handles = frames
.into_iter()
Expand All @@ -588,8 +583,7 @@ impl WayshotConnection {

rotate_join_handles
.into_iter()
.map(|join_handle| join_handle.join())
.flatten()
.flat_map(|join_handle| join_handle.join())
.fold(
None,
|composite_image: Option<Result<_>>, image: Result<_>| {
Expand Down Expand Up @@ -667,14 +661,14 @@ impl WayshotConnection {
/// Take a screenshot from all of the specified outputs.
pub fn screenshot_outputs(
&self,
outputs: &Vec<OutputInfo>,
outputs: &[OutputInfo],
cursor_overlay: bool,
) -> Result<DynamicImage> {
if outputs.is_empty() {
return Err(Error::NoOutputs);
}

self.screenshot_region_capturer(RegionCapturer::Outputs(outputs.clone()), cursor_overlay)
self.screenshot_region_capturer(RegionCapturer::Outputs(outputs.to_owned()), cursor_overlay)
}

/// Take a screenshot from all accessible outputs.
Expand Down
2 changes: 1 addition & 1 deletion libwayshot/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl EmbeddedRegion {
};

Some(Self {
relative_to: relative_to,
relative_to,
inner: Region {
position: Position { x: x1, y: y1 },
size: Size { width, height },
Expand Down
2 changes: 1 addition & 1 deletion wayshot/src/wayshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn main() -> Result<()> {
Box::new(move || {
|| -> Result<LogicalRegion> {
let slurp_output = Command::new("slurp")
.args(slurp_region.split(" "))
.args(slurp_region.split(' '))
.output()?
.stdout;

Expand Down

0 comments on commit 22d36a8

Please sign in to comment.