Skip to content

Commit c83f02e

Browse files
committed
Fix clippy::question-mark lint
Note it was necessary to add a From<std::io::Error> for Status impl for this Original clippy error: warning: this block may be rewritten with the `?` operator --> mp4parse_capi/src/lib.rs:1290:9 | 1290 | / if data_len 1291 | | .write_u32::<byteorder::NativeEndian>(content_len) 1292 | | .is_err() 1293 | | { 1294 | | return Err(Mp4parseStatus::Io); 1295 | | } | |_________^ | = note: `-D clippy::question-mark` implied by `-D warnings` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#question_mark help: replace it with | 1290 ~ data_len 1291 + .write_u32::<byteorder::NativeEndian>(content_len)?; |
1 parent e133798 commit c83f02e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

mp4parse/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ impl From<fallible_collections::TryReserveError> for Status {
227227
}
228228
}
229229

230+
impl From<std::io::Error> for Status {
231+
fn from(_: std::io::Error) -> Self {
232+
Status::Io
233+
}
234+
}
235+
230236
/// Describes parser failures.
231237
///
232238
/// This enum wraps the standard `io::Error` type, unified with

mp4parse_capi/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,12 +1287,7 @@ fn get_pssh_info(
12871287
.try_into()
12881288
.map_err(|_| Mp4parseStatus::Invalid)?;
12891289
let mut data_len = TryVec::new();
1290-
if data_len
1291-
.write_u32::<byteorder::NativeEndian>(content_len)
1292-
.is_err()
1293-
{
1294-
return Err(Mp4parseStatus::Io);
1295-
}
1290+
data_len.write_u32::<byteorder::NativeEndian>(content_len)?;
12961291
pssh_data.extend_from_slice(pssh.system_id.as_slice())?;
12971292
pssh_data.extend_from_slice(data_len.as_slice())?;
12981293
pssh_data.extend_from_slice(pssh.box_content.as_slice())?;

0 commit comments

Comments
 (0)