diff --git a/examples/transcode-audio.rs b/examples/transcode-audio.rs index 0e99b1c..d75a880 100644 --- a/examples/transcode-audio.rs +++ b/examples/transcode-audio.rs @@ -116,9 +116,9 @@ fn transcoder>( Ok(Transcoder { stream: input.index(), - filter: filter, - decoder: decoder, - encoder: encoder, + filter, + decoder, + encoder, }) } diff --git a/src/codec/audio.rs b/src/codec/audio.rs index f0f2c4a..1ea7cbc 100644 --- a/src/codec/audio.rs +++ b/src/codec/audio.rs @@ -11,7 +11,7 @@ pub struct Audio { impl Audio { pub unsafe fn new(codec: Codec) -> Audio { - Audio { codec: codec } + Audio { codec } } } @@ -63,7 +63,7 @@ pub struct RateIter { impl RateIter { pub fn new(ptr: *const i32) -> Self { - RateIter { ptr: ptr } + RateIter { ptr } } } @@ -90,7 +90,7 @@ pub struct FormatIter { impl FormatIter { pub fn new(ptr: *const AVSampleFormat) -> Self { - FormatIter { ptr: ptr } + FormatIter { ptr } } } @@ -117,7 +117,7 @@ pub struct ChannelLayoutIter { impl ChannelLayoutIter { pub fn new(ptr: *const u64) -> Self { - ChannelLayoutIter { ptr: ptr } + ChannelLayoutIter { ptr } } pub fn best(self, max: i32) -> ChannelLayout { diff --git a/src/codec/codec.rs b/src/codec/codec.rs index f733524..39f1baf 100644 --- a/src/codec/codec.rs +++ b/src/codec/codec.rs @@ -15,7 +15,7 @@ unsafe impl Sync for Codec {} impl Codec { pub unsafe fn wrap(ptr: *mut AVCodec) -> Self { - Codec { ptr: ptr } + Codec { ptr } } pub unsafe fn as_ptr(&self) -> *const AVCodec { @@ -106,7 +106,7 @@ pub struct ProfileIter { impl ProfileIter { pub fn new(id: Id, ptr: *const AVProfile) -> Self { - ProfileIter { id: id, ptr: ptr } + ProfileIter { id, ptr } } } diff --git a/src/codec/context.rs b/src/codec/context.rs index 6089538..f14ab23 100644 --- a/src/codec/context.rs +++ b/src/codec/context.rs @@ -18,10 +18,7 @@ unsafe impl Send for Context {} impl Context { pub unsafe fn wrap(ptr: *mut AVCodecContext, owner: Option>) -> Self { - Context { - ptr: ptr, - owner: owner, - } + Context { ptr, owner } } pub unsafe fn as_ptr(&self) -> *const AVCodecContext { diff --git a/src/codec/packet/borrow.rs b/src/codec/packet/borrow.rs index 65c5386..300cb5d 100644 --- a/src/codec/packet/borrow.rs +++ b/src/codec/packet/borrow.rs @@ -18,10 +18,7 @@ impl<'a> Borrow<'a> { packet.data = data.as_ptr() as *mut _; packet.size = data.len() as c_int; - Borrow { - packet: packet, - data: data, - } + Borrow { packet, data } } } diff --git a/src/codec/packet/packet.rs b/src/codec/packet/packet.rs index c2649c5..4d43bc1 100644 --- a/src/codec/packet/packet.rs +++ b/src/codec/packet/packet.rs @@ -282,7 +282,7 @@ pub struct SideDataIter<'a> { impl<'a> SideDataIter<'a> { pub fn new(ptr: *const AVPacket) -> Self { SideDataIter { - ptr: ptr, + ptr, cur: 0, _marker: PhantomData, } diff --git a/src/codec/packet/side_data.rs b/src/codec/packet/side_data.rs index 6deb8c5..558f959 100644 --- a/src/codec/packet/side_data.rs +++ b/src/codec/packet/side_data.rs @@ -155,7 +155,7 @@ pub struct SideData<'a> { impl<'a> SideData<'a> { pub unsafe fn wrap(ptr: *mut AVPacketSideData) -> Self { SideData { - ptr: ptr, + ptr, _marker: PhantomData, } } diff --git a/src/codec/parameters.rs b/src/codec/parameters.rs index 115b33f..f729a1f 100644 --- a/src/codec/parameters.rs +++ b/src/codec/parameters.rs @@ -13,10 +13,7 @@ unsafe impl Send for Parameters {} impl Parameters { pub unsafe fn wrap(ptr: *mut AVCodecParameters, owner: Option>) -> Self { - Parameters { - ptr: ptr, - owner: owner, - } + Parameters { ptr, owner } } pub unsafe fn as_ptr(&self) -> *const AVCodecParameters { diff --git a/src/codec/picture.rs b/src/codec/picture.rs index d7ae322..8deb056 100644 --- a/src/codec/picture.rs +++ b/src/codec/picture.rs @@ -26,11 +26,11 @@ impl<'a> Picture<'a> { height: u32, ) -> Self { Picture { - ptr: ptr, + ptr, - format: format, - width: width, - height: height, + format, + width, + height, _own: false, _marker: PhantomData, @@ -62,11 +62,11 @@ impl<'a> Picture<'a> { match avpicture_alloc(ptr, format.into(), width as c_int, height as c_int) { 0 => Ok(Picture { - ptr: ptr, + ptr, - format: format, - width: width, - height: height, + format, + width, + height, _own: true, _marker: PhantomData, diff --git a/src/codec/subtitle/mod.rs b/src/codec/subtitle/mod.rs index 0eb006a..afc248d 100644 --- a/src/codec/subtitle/mod.rs +++ b/src/codec/subtitle/mod.rs @@ -131,7 +131,7 @@ pub struct RectIter<'a> { impl<'a> RectIter<'a> { pub fn new(ptr: *const AVSubtitle) -> Self { RectIter { - ptr: ptr, + ptr, cur: 0, _marker: PhantomData, } @@ -175,7 +175,7 @@ pub struct RectMutIter<'a> { impl<'a> RectMutIter<'a> { pub fn new(ptr: *mut AVSubtitle) -> Self { RectMutIter { - ptr: ptr, + ptr, cur: 0, _marker: PhantomData, } diff --git a/src/codec/subtitle/rect.rs b/src/codec/subtitle/rect.rs index 0abafdc..986356b 100644 --- a/src/codec/subtitle/rect.rs +++ b/src/codec/subtitle/rect.rs @@ -55,7 +55,7 @@ pub struct Bitmap<'a> { impl<'a> Bitmap<'a> { pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self { Bitmap { - ptr: ptr, + ptr, _marker: PhantomData, } } @@ -108,7 +108,7 @@ pub struct Text<'a> { impl<'a> Text<'a> { pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self { Text { - ptr: ptr, + ptr, _marker: PhantomData, } } @@ -133,7 +133,7 @@ pub struct Ass<'a> { impl<'a> Ass<'a> { pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self { Ass { - ptr: ptr, + ptr, _marker: PhantomData, } } diff --git a/src/codec/video.rs b/src/codec/video.rs index 8e9eb95..c7a03c0 100644 --- a/src/codec/video.rs +++ b/src/codec/video.rs @@ -11,7 +11,7 @@ pub struct Video { impl Video { pub unsafe fn new(codec: Codec) -> Video { - Video { codec: codec } + Video { codec } } } @@ -51,7 +51,7 @@ pub struct RateIter { impl RateIter { pub fn new(ptr: *const AVRational) -> Self { - RateIter { ptr: ptr } + RateIter { ptr } } } @@ -78,7 +78,7 @@ pub struct FormatIter { impl FormatIter { pub fn new(ptr: *const AVPixelFormat) -> Self { - FormatIter { ptr: ptr } + FormatIter { ptr } } } diff --git a/src/device/extensions.rs b/src/device/extensions.rs index 3b7f224..95349a0 100644 --- a/src/device/extensions.rs +++ b/src/device/extensions.rs @@ -28,7 +28,7 @@ impl<'a> DeviceIter<'a> { n if n < 0 => Err(Error::from(n)), _ => Ok(DeviceIter { - ptr: ptr, + ptr, cur: 0, _marker: PhantomData, }), diff --git a/src/device/mod.rs b/src/device/mod.rs index 792bcd5..779f9e7 100644 --- a/src/device/mod.rs +++ b/src/device/mod.rs @@ -17,7 +17,7 @@ pub struct Info<'a> { impl<'a> Info<'a> { pub unsafe fn wrap(ptr: *mut AVDeviceInfo) -> Self { Info { - ptr: ptr, + ptr, _marker: PhantomData, } } diff --git a/src/filter/context/context.rs b/src/filter/context/context.rs index d2145df..f49eaf4 100644 --- a/src/filter/context/context.rs +++ b/src/filter/context/context.rs @@ -14,7 +14,7 @@ pub struct Context<'a> { impl<'a> Context<'a> { pub unsafe fn wrap(ptr: *mut AVFilterContext) -> Self { Context { - ptr: ptr, + ptr, _marker: PhantomData, } } diff --git a/src/filter/context/sink.rs b/src/filter/context/sink.rs index 1a79b93..0c744e4 100644 --- a/src/filter/context/sink.rs +++ b/src/filter/context/sink.rs @@ -9,7 +9,7 @@ pub struct Sink<'a> { impl<'a> Sink<'a> { pub unsafe fn wrap<'b>(ctx: &'b mut Context<'b>) -> Sink<'b> { - Sink { ctx: ctx } + Sink { ctx } } } diff --git a/src/filter/context/source.rs b/src/filter/context/source.rs index 1b934f5..58ac781 100644 --- a/src/filter/context/source.rs +++ b/src/filter/context/source.rs @@ -10,7 +10,7 @@ pub struct Source<'a> { impl<'a> Source<'a> { pub unsafe fn wrap<'b>(ctx: &'b mut Context<'b>) -> Source<'b> { - Source { ctx: ctx } + Source { ctx } } } diff --git a/src/filter/filter.rs b/src/filter/filter.rs index 804ab69..9384189 100644 --- a/src/filter/filter.rs +++ b/src/filter/filter.rs @@ -11,7 +11,7 @@ pub struct Filter { impl Filter { pub unsafe fn wrap(ptr: *mut AVFilter) -> Self { - Filter { ptr: ptr } + Filter { ptr } } pub unsafe fn as_ptr(&self) -> *const AVFilter { @@ -79,7 +79,7 @@ pub struct PadIter<'a> { impl<'a> PadIter<'a> { pub fn new(ptr: *const AVFilterPad) -> Self { PadIter { - ptr: ptr, + ptr, cur: 0, _marker: PhantomData, } diff --git a/src/filter/graph.rs b/src/filter/graph.rs index c2ae441..1654e6e 100644 --- a/src/filter/graph.rs +++ b/src/filter/graph.rs @@ -16,7 +16,7 @@ unsafe impl Sync for Graph {} impl Graph { pub unsafe fn wrap(ptr: *mut AVFilterGraph) -> Self { - Graph { ptr: ptr } + Graph { ptr } } pub unsafe fn as_ptr(&self) -> *const AVFilterGraph { @@ -136,7 +136,7 @@ pub struct Parser<'a> { impl<'a> Parser<'a> { pub fn new(graph: &mut Graph) -> Parser { Parser { - graph: graph, + graph, inputs: ptr::null_mut(), outputs: ptr::null_mut(), } diff --git a/src/filter/pad.rs b/src/filter/pad.rs index fce32a8..9dc5097 100644 --- a/src/filter/pad.rs +++ b/src/filter/pad.rs @@ -15,8 +15,8 @@ pub struct Pad<'a> { impl<'a> Pad<'a> { pub unsafe fn wrap(ptr: *const AVFilterPad, idx: isize) -> Self { Pad { - ptr: ptr, - idx: idx, + ptr, + idx, _marker: PhantomData, } } diff --git a/src/format/chapter/chapter.rs b/src/format/chapter/chapter.rs index 7d30ff4..1b56b37 100644 --- a/src/format/chapter/chapter.rs +++ b/src/format/chapter/chapter.rs @@ -12,10 +12,7 @@ pub struct Chapter<'a> { impl<'a> Chapter<'a> { pub unsafe fn wrap(context: &Context, index: usize) -> Chapter { - Chapter { - context: context, - index: index, - } + Chapter { context, index } } pub unsafe fn as_ptr(&self) -> *const AVChapter { diff --git a/src/format/chapter/chapter_mut.rs b/src/format/chapter/chapter_mut.rs index 99a3a0f..5f9d7f5 100644 --- a/src/format/chapter/chapter_mut.rs +++ b/src/format/chapter/chapter_mut.rs @@ -19,7 +19,7 @@ impl<'a> ChapterMut<'a> { pub unsafe fn wrap(context: &mut Context, index: usize) -> ChapterMut { ChapterMut { context: mem::transmute_copy(&context), - index: index, + index, immutable: Chapter::wrap(mem::transmute_copy(&context), index), } diff --git a/src/format/context/common.rs b/src/format/context/common.rs index 44db2d7..e441681 100644 --- a/src/format/context/common.rs +++ b/src/format/context/common.rs @@ -17,7 +17,7 @@ unsafe impl Send for Context {} impl Context { pub unsafe fn wrap(ptr: *mut AVFormatContext, mode: destructor::Mode) -> Self { Context { - ptr: ptr, + ptr, dtor: Rc::new(Destructor::new(ptr, mode)), } } @@ -131,7 +131,7 @@ pub struct Best<'a> { impl<'a> Best<'a> { pub unsafe fn new<'b, 'c: 'b>(context: &'c Context) -> Best<'b> { Best { - context: context, + context, wanted: -1, related: -1, @@ -186,7 +186,7 @@ pub struct StreamIter<'a> { impl<'a> StreamIter<'a> { pub fn new<'s, 'c: 's>(context: &'c Context) -> StreamIter<'s> { StreamIter { - context: context, + context, current: 0, } } @@ -254,7 +254,7 @@ pub struct StreamIterMut<'a> { impl<'a> StreamIterMut<'a> { pub fn new<'s, 'c: 's>(context: &'c mut Context) -> StreamIterMut<'s> { StreamIterMut { - context: context, + context, current: 0, } } @@ -300,7 +300,7 @@ pub struct ChapterIter<'a> { impl<'a> ChapterIter<'a> { pub fn new<'s, 'c: 's>(context: &'c Context) -> ChapterIter<'s> { ChapterIter { - context: context, + context, current: 0, } } @@ -343,7 +343,7 @@ pub struct ChapterIterMut<'a> { impl<'a> ChapterIterMut<'a> { pub fn new<'s, 'c: 's>(context: &'c mut Context) -> ChapterIterMut<'s> { ChapterIterMut { - context: context, + context, current: 0, } } diff --git a/src/format/context/destructor.rs b/src/format/context/destructor.rs index cf2a885..fa36d42 100644 --- a/src/format/context/destructor.rs +++ b/src/format/context/destructor.rs @@ -13,10 +13,7 @@ pub struct Destructor { impl Destructor { pub unsafe fn new(ptr: *mut AVFormatContext, mode: Mode) -> Self { - Destructor { - ptr: ptr, - mode: mode, - } + Destructor { ptr, mode } } } diff --git a/src/format/context/input.rs b/src/format/context/input.rs index 542455c..871b527 100644 --- a/src/format/context/input.rs +++ b/src/format/context/input.rs @@ -19,7 +19,7 @@ unsafe impl Send for Input {} impl Input { pub unsafe fn wrap(ptr: *mut AVFormatContext) -> Self { Input { - ptr: ptr, + ptr, ctx: Context::wrap(ptr, destructor::Mode::Input), } } @@ -149,7 +149,7 @@ pub struct PacketIter<'a> { impl<'a> PacketIter<'a> { pub fn new(context: &mut Input) -> PacketIter { - PacketIter { context: context } + PacketIter { context } } } diff --git a/src/format/context/output.rs b/src/format/context/output.rs index 4bda2a5..986715d 100644 --- a/src/format/context/output.rs +++ b/src/format/context/output.rs @@ -21,7 +21,7 @@ unsafe impl Send for Output {} impl Output { pub unsafe fn wrap(ptr: *mut AVFormatContext) -> Self { Output { - ptr: ptr, + ptr, ctx: Context::wrap(ptr, destructor::Mode::Output), } } diff --git a/src/format/format/input.rs b/src/format/format/input.rs index 4184252..279e82c 100644 --- a/src/format/format/input.rs +++ b/src/format/format/input.rs @@ -9,7 +9,7 @@ pub struct Input { impl Input { pub unsafe fn wrap(ptr: *mut AVInputFormat) -> Self { - Input { ptr: ptr } + Input { ptr } } pub unsafe fn as_ptr(&self) -> *const AVInputFormat { diff --git a/src/format/format/output.rs b/src/format/format/output.rs index e758ea9..fdad350 100644 --- a/src/format/format/output.rs +++ b/src/format/format/output.rs @@ -14,7 +14,7 @@ pub struct Output { impl Output { pub unsafe fn wrap(ptr: *mut AVOutputFormat) -> Self { - Output { ptr: ptr } + Output { ptr } } pub unsafe fn as_ptr(&self) -> *const AVOutputFormat { diff --git a/src/format/stream/stream.rs b/src/format/stream/stream.rs index c6a2d84..0ddac24 100644 --- a/src/format/stream/stream.rs +++ b/src/format/stream/stream.rs @@ -12,10 +12,7 @@ pub struct Stream<'a> { impl<'a> Stream<'a> { pub unsafe fn wrap(context: &Context, index: usize) -> Stream { - Stream { - context: context, - index: index, - } + Stream { context, index } } pub unsafe fn as_ptr(&self) -> *const AVStream { @@ -98,10 +95,7 @@ pub struct SideDataIter<'a> { impl<'a> SideDataIter<'a> { pub fn new<'sd, 's: 'sd>(stream: &'s Stream) -> SideDataIter<'sd> { - SideDataIter { - stream: stream, - current: 0, - } + SideDataIter { stream, current: 0 } } } diff --git a/src/format/stream/stream_mut.rs b/src/format/stream/stream_mut.rs index 8062b61..5e69376 100644 --- a/src/format/stream/stream_mut.rs +++ b/src/format/stream/stream_mut.rs @@ -17,7 +17,7 @@ impl<'a> StreamMut<'a> { pub unsafe fn wrap(context: &mut Context, index: usize) -> StreamMut { StreamMut { context: mem::transmute_copy(&context), - index: index, + index, immutable: Stream::wrap(mem::transmute_copy(&context), index), } diff --git a/src/software/resampling/context.rs b/src/software/resampling/context.rs index 43944eb..fc3902c 100644 --- a/src/software/resampling/context.rs +++ b/src/software/resampling/context.rs @@ -60,7 +60,7 @@ impl Context { e if e < 0 => Err(Error::from(e)), _ => Ok(Context { - ptr: ptr, + ptr, input: Definition { format: src_format, diff --git a/src/software/scaling/context.rs b/src/software/scaling/context.rs index 72b8b7c..4487b56 100644 --- a/src/software/scaling/context.rs +++ b/src/software/scaling/context.rs @@ -58,7 +58,7 @@ impl Context { if !ptr.is_null() { Ok(Context { - ptr: ptr, + ptr, input: Definition { format: src_format, diff --git a/src/software/scaling/vector.rs b/src/software/scaling/vector.rs index b1e19ad..9a3668b 100644 --- a/src/software/scaling/vector.rs +++ b/src/software/scaling/vector.rs @@ -14,7 +14,7 @@ pub struct Vector<'a> { impl<'a> Vector<'a> { pub unsafe fn wrap(ptr: *mut SwsVector) -> Self { Vector { - ptr: ptr, + ptr, _own: false, _marker: PhantomData, } diff --git a/src/util/dictionary/immutable.rs b/src/util/dictionary/immutable.rs index 058547f..3781277 100644 --- a/src/util/dictionary/immutable.rs +++ b/src/util/dictionary/immutable.rs @@ -15,7 +15,7 @@ pub struct Ref<'a> { impl<'a> Ref<'a> { pub unsafe fn wrap(ptr: *const AVDictionary) -> Self { Ref { - ptr: ptr, + ptr, _marker: PhantomData, } } diff --git a/src/util/dictionary/mutable.rs b/src/util/dictionary/mutable.rs index 7e345fb..5413dfd 100644 --- a/src/util/dictionary/mutable.rs +++ b/src/util/dictionary/mutable.rs @@ -15,7 +15,7 @@ pub struct Ref<'a> { impl<'a> Ref<'a> { pub unsafe fn wrap(ptr: *mut AVDictionary) -> Self { Ref { - ptr: ptr, + ptr, imm: immutable::Ref::wrap(ptr), _marker: PhantomData, } diff --git a/src/util/format/sample.rs b/src/util/format/sample.rs index 0adae38..901b8c4 100644 --- a/src/util/format/sample.rs +++ b/src/util/format/sample.rs @@ -153,10 +153,10 @@ impl Buffer { pub fn new(format: Sample, channels: u16, samples: usize, align: bool) -> Self { unsafe { let mut buf = Buffer { - format: format, - channels: channels, - samples: samples, - align: align, + format, + channels, + samples, + align, buffer: ptr::null_mut(), size: 0, diff --git a/src/util/frame/mod.rs b/src/util/frame/mod.rs index 204ab2a..bbbd1d9 100644 --- a/src/util/frame/mod.rs +++ b/src/util/frame/mod.rs @@ -37,10 +37,7 @@ unsafe impl Sync for Frame {} impl Frame { #[inline(always)] pub unsafe fn wrap(ptr: *mut AVFrame) -> Self { - Frame { - ptr: ptr, - _own: false, - } + Frame { ptr, _own: false } } #[inline(always)] diff --git a/src/util/frame/side_data.rs b/src/util/frame/side_data.rs index 8a6ce96..2abbf43 100644 --- a/src/util/frame/side_data.rs +++ b/src/util/frame/side_data.rs @@ -146,7 +146,7 @@ impl<'a> SideData<'a> { #[inline(always)] pub unsafe fn wrap(ptr: *mut AVFrameSideData) -> Self { SideData { - ptr: ptr, + ptr, _marker: PhantomData, } }