Skip to content

Commit 0ff456e

Browse files
committed
Passes format [u8; 4] by value instead of reference, per trivially_copy_pass_by_ref lint
1 parent f32583d commit 0ff456e

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

examples/complex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn main() {
99
for wformat in camera.formats() {
1010
let format = wformat.unwrap();
1111
println!("{:?}", format);
12-
println!(" {:?}", camera.resolutions(&format.format).unwrap());
12+
println!(" {:?}", camera.resolutions(format.format).unwrap());
1313
}
1414

1515
camera

examples/formats.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ fn main() {
99
let format = wformat.unwrap();
1010
println!("{:?}", format);
1111

12-
let resolutions = camera.resolutions(&format.format).unwrap();
12+
let resolutions = camera.resolutions(format.format).unwrap();
1313

1414
if let ResolutionInfo::Discretes(d) = resolutions {
1515
for resol in &d {
1616
println!(
1717
" {}x{} {:?}",
1818
resol.0,
1919
resol.1,
20-
camera.intervals(&format.format, *resol).unwrap()
20+
camera.intervals(format.format, *resol).unwrap()
2121
);
2222
}
2323
} else {

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl FormatInfo {
160160
}
161161
}
162162

163-
fn fourcc(fmt: &[u8; 4]) -> u32 {
163+
fn fourcc(fmt: [u8; 4]) -> u32 {
164164
u32::from(fmt[0])
165165
| (u32::from(fmt[1])) << 8
166166
| (u32::from(fmt[2])) << 16
@@ -315,7 +315,7 @@ impl Camera {
315315
}
316316

317317
/// Get detailed info about the available resolutions.
318-
pub fn resolutions(&self, format: &[u8; 4]) -> Result<ResolutionInfo> {
318+
pub fn resolutions(&self, format: [u8; 4]) -> Result<ResolutionInfo> {
319319
let fourcc = FormatInfo::fourcc(format);
320320
let mut size = v4l2::Frmsizeenum::new(fourcc);
321321

@@ -350,7 +350,7 @@ impl Camera {
350350
}
351351

352352
/// Get detailed info about the available intervals.
353-
pub fn intervals(&self, format: &[u8; 4], resolution: (u32, u32)) -> Result<IntervalInfo> {
353+
pub fn intervals(&self, format: [u8; 4], resolution: (u32, u32)) -> Result<IntervalInfo> {
354354
let fourcc = FormatInfo::fourcc(format);
355355
let mut ival = v4l2::Frmivalenum::new(fourcc, resolution);
356356

@@ -551,7 +551,7 @@ impl Camera {
551551
pub fn start(&mut self, config: &Config) -> Result<()> {
552552
assert_eq!(self.state, State::Idle);
553553

554-
self.tune_format(config.resolution, config.format, config.field)?;
554+
self.tune_format(config.resolution, *config.format, config.field)?;
555555
self.tune_stream(config.interval)?;
556556
self.alloc_buffers(config.nbuffers)?;
557557

@@ -611,7 +611,7 @@ impl Camera {
611611
Ok(())
612612
}
613613

614-
fn tune_format(&self, resolution: (u32, u32), format: &[u8; 4], field: u32) -> Result<()> {
614+
fn tune_format(&self, resolution: (u32, u32), format: [u8; 4], field: u32) -> Result<()> {
615615
let fourcc = FormatInfo::fourcc(format);
616616
let mut fmt = v4l2::Format::new(resolution, fourcc, field as u32);
617617

0 commit comments

Comments
 (0)