Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some small Clippy lints + format Cargo.toml #112

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

onkoe
Copy link

@onkoe onkoe commented Sep 5, 2024

Nothing fancy here! Please let me know if any of these are unwanted changes.

seems like this file was added with the "deprecated" doc-comment.

i assume no one has ever used it, and it's not referenced in the code anywhere

might be a good idea to remove this in a major release
since the generics are only used once, the compiler knows them already
Copy link
Collaborator

@MarijnS95 MarijnS95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we (unfortunately) have to tackle a lot more on the consistency front (separate from cleaning up lint nits) too :/

Comment on lines 28 to +29
/// Deprecated, do not use
#[deprecated]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Deprecated, do not use
#[deprecated]
#[deprecated = "do not use"]

?

Comment on lines 156 to 161
Err(e) => {
if controls.is_empty() || e.kind() != io::ErrorKind::InvalidInput {
return Err(e);
} else {
break;
}
break;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could've almost written something like break if ... { Err(e) } else { Ok(controls) }; showing that this is the only exit.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah, that works just fine! I'm somewhat unfamiliar with this syntax, so please do check to ensure it's right:

Suggested change
Err(e) => {
if controls.is_empty() || e.kind() != io::ErrorKind::InvalidInput {
return Err(e);
} else {
break;
}
break;
}
Err(e) => {
break if controls.is_empty() || e.kind() != io::ErrorKind::InvalidInput {
Err(e)
} else {
Ok(controls)
};

@@ -27,9 +27,8 @@ macro_rules! impl_enum_frameintervals {
if ret.is_err() {
if v4l2_struct.index == 0 {
return Err(ret.err().unwrap());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No conversion here, can we use if let Err(e) to get rid of the unwrap()?

Comment on lines 28 to 34
if v4l2_struct.index == 0 {
return Err(ret.err().unwrap());
} else {
return Ok(frameintervals);
}
return Ok(frameintervals);
}

if let Ok(frame_interval) = FrameInterval::try_from(v4l2_struct) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what you were thinking about? It's a little scary in the macro, but cargo check is happy!

Suggested change
if v4l2_struct.index == 0 {
return Err(ret.err().unwrap());
} else {
return Ok(frameintervals);
}
return Ok(frameintervals);
}
if let Ok(frame_interval) = FrameInterval::try_from(v4l2_struct) {
if let Err(e) = ret {
if v4l2_struct.index == 0 {
return Err(e);
}
return Ok(frameintervals);
}
if let Ok(frame_interval) = FrameInterval::try_from(v4l2_struct) {

@@ -26,6 +26,7 @@ pub enum Type {
MetaOutput = 14,

/// Deprecated, do not use
#[deprecated]
Private = 0x80,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this may not be useful. If you have a better reason than "do not use", it'd work much better here! :D

Suggested change
Private = 0x80,
#[deprecated(note = "do not use")]
Private = 0x80,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants