From 8585016720cb335a09bf863bacd032e6ab641ba2 Mon Sep 17 00:00:00 2001 From: Takeru Ohta Date: Thu, 4 Oct 2018 20:18:56 +0900 Subject: [PATCH] Apply rustfmt-0.99.1 --- examples/parse.rs | 5 ++--- src/line.rs | 2 +- src/master_playlist.rs | 16 ++++++++-------- src/media_playlist.rs | 19 +++++++++---------- src/media_segment.rs | 11 ++++++----- src/tags/basic.rs | 2 +- src/tags/master_playlist.rs | 14 ++++++++------ src/tags/media_or_master_playlist.rs | 4 ++-- src/tags/media_playlist.rs | 2 +- src/tags/media_segment.rs | 13 +++++++------ src/tags/mod.rs | 20 ++++++++++++-------- src/types.rs | 2 +- 12 files changed, 58 insertions(+), 52 deletions(-) diff --git a/examples/parse.rs b/examples/parse.rs index 10b5f04..e617c36 100644 --- a/examples/parse.rs +++ b/examples/parse.rs @@ -3,9 +3,9 @@ extern crate hls_m3u8; #[macro_use] extern crate trackable; -use std::io::{self, Read}; use clap::{App, Arg}; use hls_m3u8::{MasterPlaylist, MediaPlaylist}; +use std::io::{self, Read}; use trackable::error::Failure; fn main() { @@ -16,8 +16,7 @@ fn main() { .takes_value(true) .default_value("media") .possible_values(&["media", "master"]), - ) - .get_matches(); + ).get_matches(); let mut m3u8 = String::new(); track_try_unwrap!( io::stdin() diff --git a/src/line.rs b/src/line.rs index 29f5b34..386cc1a 100644 --- a/src/line.rs +++ b/src/line.rs @@ -1,9 +1,9 @@ use std::fmt; use std::str::FromStr; -use {Error, ErrorKind, Result}; use tags; use types::SingleLineString; +use {Error, ErrorKind, Result}; #[derive(Debug)] pub struct Lines<'a> { diff --git a/src/master_playlist.rs b/src/master_playlist.rs index b3e6660..e96a837 100644 --- a/src/master_playlist.rs +++ b/src/master_playlist.rs @@ -1,13 +1,15 @@ use std::collections::HashSet; -use std::iter; use std::fmt; +use std::iter; use std::str::FromStr; -use {Error, ErrorKind, Result}; use line::{Line, Lines, Tag}; -use tags::{ExtM3u, ExtXIFrameStreamInf, ExtXIndependentSegments, ExtXMedia, ExtXSessionData, - ExtXSessionKey, ExtXStart, ExtXStreamInf, ExtXVersion, MasterPlaylistTag}; +use tags::{ + ExtM3u, ExtXIFrameStreamInf, ExtXIndependentSegments, ExtXMedia, ExtXSessionData, + ExtXSessionKey, ExtXStart, ExtXStreamInf, ExtXVersion, MasterPlaylistTag, +}; use types::{ClosedCaptions, MediaType, ProtocolVersion, QuotedString}; +use {Error, ErrorKind, Result}; /// Master playlist builder. #[derive(Debug, Clone)] @@ -100,16 +102,14 @@ impl MasterPlaylistBuilder { self.independent_segments_tag .iter() .map(|t| t.requires_version()), - ) - .chain(self.start_tag.iter().map(|t| t.requires_version())) + ).chain(self.start_tag.iter().map(|t| t.requires_version())) .chain(self.media_tags.iter().map(|t| t.requires_version())) .chain(self.stream_inf_tags.iter().map(|t| t.requires_version())) .chain( self.i_frame_stream_inf_tags .iter() .map(|t| t.requires_version()), - ) - .chain(self.session_data_tags.iter().map(|t| t.requires_version())) + ).chain(self.session_data_tags.iter().map(|t| t.requires_version())) .chain(self.session_key_tags.iter().map(|t| t.requires_version())) .max() .expect("Never fails") diff --git a/src/media_playlist.rs b/src/media_playlist.rs index b26e3d0..9ecd778 100644 --- a/src/media_playlist.rs +++ b/src/media_playlist.rs @@ -3,13 +3,15 @@ use std::iter; use std::str::FromStr; use std::time::Duration; -use {Error, ErrorKind, Result}; use line::{Line, Lines, Tag}; use media_segment::{MediaSegment, MediaSegmentBuilder}; -use tags::{ExtM3u, ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, - ExtXIndependentSegments, ExtXMediaSequence, ExtXPlaylistType, ExtXStart, - ExtXTargetDuration, ExtXVersion, MediaPlaylistTag}; +use tags::{ + ExtM3u, ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, ExtXIndependentSegments, + ExtXMediaSequence, ExtXPlaylistType, ExtXStart, ExtXTargetDuration, ExtXVersion, + MediaPlaylistTag, +}; use types::ProtocolVersion; +use {Error, ErrorKind, Result}; /// Media playlist builder. #[derive(Debug, Clone)] @@ -148,21 +150,18 @@ impl MediaPlaylistBuilder { self.target_duration_tag .iter() .map(|t| t.requires_version()), - ) - .chain(self.media_sequence_tag.iter().map(|t| t.requires_version())) + ).chain(self.media_sequence_tag.iter().map(|t| t.requires_version())) .chain( self.discontinuity_sequence_tag .iter() .map(|t| t.requires_version()), - ) - .chain(self.playlist_type_tag.iter().map(|t| t.requires_version())) + ).chain(self.playlist_type_tag.iter().map(|t| t.requires_version())) .chain(self.i_frames_only_tag.iter().map(|t| t.requires_version())) .chain( self.independent_segments_tag .iter() .map(|t| t.requires_version()), - ) - .chain(self.start_tag.iter().map(|t| t.requires_version())) + ).chain(self.start_tag.iter().map(|t| t.requires_version())) .chain(self.end_list_tag.iter().map(|t| t.requires_version())) .chain(self.segments.iter().map(|s| s.requires_version())) .max() diff --git a/src/media_segment.rs b/src/media_segment.rs index 9666b8c..c3012de 100644 --- a/src/media_segment.rs +++ b/src/media_segment.rs @@ -1,10 +1,12 @@ use std::fmt; use std::iter; -use {ErrorKind, Result}; -use tags::{ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXMap, - ExtXProgramDateTime, MediaSegmentTag}; +use tags::{ + ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXMap, ExtXProgramDateTime, + MediaSegmentTag, +}; use types::{ProtocolVersion, SingleLineString}; +use {ErrorKind, Result}; /// Media segment builder. #[derive(Debug, Clone)] @@ -165,8 +167,7 @@ impl MediaSegment { self.program_date_time_tag .iter() .map(|t| t.requires_version()), - ) - .chain(iter::once(self.inf_tag.requires_version())) + ).chain(iter::once(self.inf_tag.requires_version())) .max() .expect("Never fails") } diff --git a/src/tags/basic.rs b/src/tags/basic.rs index 997c88d..6d0924c 100644 --- a/src/tags/basic.rs +++ b/src/tags/basic.rs @@ -1,8 +1,8 @@ use std::fmt; use std::str::FromStr; -use {Error, ErrorKind, Result}; use types::ProtocolVersion; +use {Error, ErrorKind, Result}; /// [4.3.1.1. EXTM3U] /// diff --git a/src/tags/master_playlist.rs b/src/tags/master_playlist.rs index 43ba694..44373cd 100644 --- a/src/tags/master_playlist.rs +++ b/src/tags/master_playlist.rs @@ -1,11 +1,13 @@ use std::fmt; use std::str::FromStr; -use {Error, ErrorKind, Result}; +use super::{parse_u64, parse_yes_or_no}; use attribute::AttributePairs; -use types::{ClosedCaptions, DecimalFloatingPoint, DecimalResolution, DecryptionKey, HdcpLevel, - InStreamId, MediaType, ProtocolVersion, QuotedString, SessionData, SingleLineString}; -use super::{parse_yes_or_no, parse_u64}; +use types::{ + ClosedCaptions, DecimalFloatingPoint, DecimalResolution, DecryptionKey, HdcpLevel, InStreamId, + MediaType, ProtocolVersion, QuotedString, SessionData, SingleLineString, +}; +use {Error, ErrorKind, Result}; /// `ExtXMedia` builder. #[derive(Debug, Clone)] @@ -834,8 +836,8 @@ impl FromStr for ExtXSessionKey { #[cfg(test)] mod test { - use types::{EncryptionMethod, InitializationVector}; use super::*; + use types::{EncryptionMethod, InitializationVector}; #[test] fn ext_x_media() { @@ -899,7 +901,7 @@ mod test { method: EncryptionMethod::Aes128, uri: quoted_string("foo"), iv: Some(InitializationVector([ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ])), key_format: None, key_format_versions: None, diff --git a/src/tags/media_or_master_playlist.rs b/src/tags/media_or_master_playlist.rs index 879969d..8dc6a7d 100644 --- a/src/tags/media_or_master_playlist.rs +++ b/src/tags/media_or_master_playlist.rs @@ -1,10 +1,10 @@ use std::fmt; use std::str::FromStr; -use {Error, ErrorKind, Result}; +use super::parse_yes_or_no; use attribute::AttributePairs; use types::{ProtocolVersion, SignedDecimalFloatingPoint}; -use super::parse_yes_or_no; +use {Error, ErrorKind, Result}; /// [4.3.5.1. EXT-X-INDEPENDENT-SEGMENTS] /// diff --git a/src/tags/media_playlist.rs b/src/tags/media_playlist.rs index 899e3a3..d917e99 100644 --- a/src/tags/media_playlist.rs +++ b/src/tags/media_playlist.rs @@ -3,8 +3,8 @@ use std::str::FromStr; use std::time::Duration; use trackable::error::ErrorKindExt; -use {Error, ErrorKind, Result}; use types::{PlaylistType, ProtocolVersion}; +use {Error, ErrorKind, Result}; /// [4.3.3.1. EXT-X-TARGETDURATION] /// diff --git a/src/tags/media_segment.rs b/src/tags/media_segment.rs index e89326f..d505f01 100644 --- a/src/tags/media_segment.rs +++ b/src/tags/media_segment.rs @@ -4,10 +4,11 @@ use std::str::FromStr; use std::time::Duration; use trackable::error::ErrorKindExt; -use {Error, ErrorKind, Result}; use attribute::AttributePairs; -use types::{ByteRange, DecimalFloatingPoint, DecryptionKey, ProtocolVersion, QuotedString, - SingleLineString}; +use types::{ + ByteRange, DecimalFloatingPoint, DecryptionKey, ProtocolVersion, QuotedString, SingleLineString, +}; +use {Error, ErrorKind, Result}; /// [4.3.2.1. EXTINF] /// @@ -480,8 +481,8 @@ impl FromStr for ExtXDateRange { mod test { use std::time::Duration; - use types::{EncryptionMethod, InitializationVector}; use super::*; + use types::{EncryptionMethod, InitializationVector}; #[test] fn extinf() { @@ -555,7 +556,7 @@ mod test { method: EncryptionMethod::Aes128, uri: QuotedString::new("foo").unwrap(), iv: Some(InitializationVector([ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ])), key_format: None, key_format_versions: None, @@ -569,7 +570,7 @@ mod test { method: EncryptionMethod::Aes128, uri: QuotedString::new("foo").unwrap(), iv: Some(InitializationVector([ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ])), key_format: Some(QuotedString::new("baz").unwrap()), key_format_versions: None, diff --git a/src/tags/mod.rs b/src/tags/mod.rs index 7f2a9c4..6b28f8b 100644 --- a/src/tags/mod.rs +++ b/src/tags/mod.rs @@ -8,7 +8,7 @@ use {ErrorKind, Result}; macro_rules! may_invalid { ($expr:expr) => { $expr.map_err(|e| track!(Error::from(ErrorKind::InvalidInput.cause(e)))) - } + }; } macro_rules! impl_from { @@ -18,17 +18,21 @@ macro_rules! impl_from { $to::$from(f) } } - } + }; } pub use self::basic::{ExtM3u, ExtXVersion}; -pub use self::master_playlist::{ExtXIFrameStreamInf, ExtXMedia, ExtXSessionData, ExtXSessionKey, - ExtXStreamInf}; +pub use self::master_playlist::{ + ExtXIFrameStreamInf, ExtXMedia, ExtXSessionData, ExtXSessionKey, ExtXStreamInf, +}; pub use self::media_or_master_playlist::{ExtXIndependentSegments, ExtXStart}; -pub use self::media_playlist::{ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, - ExtXMediaSequence, ExtXPlaylistType, ExtXTargetDuration}; -pub use self::media_segment::{ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, - ExtXMap, ExtXProgramDateTime}; +pub use self::media_playlist::{ + ExtXDiscontinuitySequence, ExtXEndList, ExtXIFramesOnly, ExtXMediaSequence, ExtXPlaylistType, + ExtXTargetDuration, +}; +pub use self::media_segment::{ + ExtInf, ExtXByteRange, ExtXDateRange, ExtXDiscontinuity, ExtXKey, ExtXMap, ExtXProgramDateTime, +}; mod basic; mod master_playlist; diff --git a/src/types.rs b/src/types.rs index c943120..cf24cfb 100644 --- a/src/types.rs +++ b/src/types.rs @@ -5,8 +5,8 @@ use std::str::{self, FromStr}; use std::time::Duration; use trackable::error::ErrorKindExt; -use {Error, ErrorKind, Result}; use attribute::AttributePairs; +use {Error, ErrorKind, Result}; /// String that represents a single line in a playlist file. ///