Fix various minor clippy warnings

This commit is contained in:
Sebastian Dröge 2021-11-18 14:54:46 +02:00
parent 7e62854e20
commit 3edf5d1c0f
3 changed files with 7 additions and 5 deletions

View file

@ -9,7 +9,7 @@ fn main() {
let parsed = m3u8_rs::parse_playlist(&bytes);
let playlist = match parsed {
Result::Ok((i, playlist)) => playlist,
Result::Ok((_i, playlist)) => playlist,
Result::Err(e) => panic!("Parsing error: \n{}", e),
};
@ -19,6 +19,7 @@ fn main() {
}
}
#[allow(unused)]
fn main_alt() {
let mut file = std::fs::File::open("playlist.m3u8").unwrap();
let mut bytes: Vec<u8> = Vec::new();
@ -27,8 +28,8 @@ fn main_alt() {
let parsed = m3u8_rs::parse_playlist(&bytes);
match parsed {
Result::Ok((i, Playlist::MasterPlaylist(pl))) => println!("Master playlist:\n{:?}", pl),
Result::Ok((i, Playlist::MediaPlaylist(pl))) => println!("Media playlist:\n{:?}", pl),
Result::Ok((_i, Playlist::MasterPlaylist(pl))) => println!("Master playlist:\n{:?}", pl),
Result::Ok((_i, Playlist::MediaPlaylist(pl))) => println!("Media playlist:\n{:?}", pl),
Result::Err(e) => panic!("Parsing error: \n{}", e),
}
}

View file

@ -271,6 +271,7 @@ fn parse_master_playlist_tags(i: &[u8]) -> IResult<&[u8], Vec<MasterPlaylistTag>
}
/// Contains all the tags required to parse a master playlist.
#[allow(clippy::large_enum_variant)]
#[derive(Debug)]
enum MasterPlaylistTag {
Version(usize),

View file

@ -21,7 +21,7 @@ fn all_sample_m3u_playlists() -> Vec<path::PathBuf> {
fn getm3u(path: &str) -> String {
let mut buf = String::new();
let mut file = fs::File::open(path).expect(&format!("Can't find m3u8: {}", path));
let mut file = fs::File::open(path).unwrap_or_else(|_| panic!("Can't find m3u8: {}", path));
let u = file.read_to_string(&mut buf).expect("Can't read file");
buf
}
@ -139,7 +139,7 @@ fn playlist_not_ending_in_newline_media() {
fn playlist_type_is_master() {
let input = get_sample_playlist("master.m3u8");
let result = is_master_playlist(input.as_bytes());
assert_eq!(true, result);
assert!(result);
}
// #[test]