Fix clippy::redundant_field_names

This commit is contained in:
Zhiming Wang 2020-07-26 01:01:13 +08:00
parent ceb1a7ea7c
commit 73b66ea438
No known key found for this signature in database
GPG Key ID: 5B58F95EC95965D8
38 changed files with 69 additions and 93 deletions

View File

@ -116,9 +116,9 @@ fn transcoder<P: AsRef<Path>>(
Ok(Transcoder { Ok(Transcoder {
stream: input.index(), stream: input.index(),
filter: filter, filter,
decoder: decoder, decoder,
encoder: encoder, encoder,
}) })
} }

View File

@ -11,7 +11,7 @@ pub struct Audio {
impl Audio { impl Audio {
pub unsafe fn new(codec: Codec) -> Audio { pub unsafe fn new(codec: Codec) -> Audio {
Audio { codec: codec } Audio { codec }
} }
} }
@ -63,7 +63,7 @@ pub struct RateIter {
impl RateIter { impl RateIter {
pub fn new(ptr: *const i32) -> Self { pub fn new(ptr: *const i32) -> Self {
RateIter { ptr: ptr } RateIter { ptr }
} }
} }
@ -90,7 +90,7 @@ pub struct FormatIter {
impl FormatIter { impl FormatIter {
pub fn new(ptr: *const AVSampleFormat) -> Self { pub fn new(ptr: *const AVSampleFormat) -> Self {
FormatIter { ptr: ptr } FormatIter { ptr }
} }
} }
@ -117,7 +117,7 @@ pub struct ChannelLayoutIter {
impl ChannelLayoutIter { impl ChannelLayoutIter {
pub fn new(ptr: *const u64) -> Self { pub fn new(ptr: *const u64) -> Self {
ChannelLayoutIter { ptr: ptr } ChannelLayoutIter { ptr }
} }
pub fn best(self, max: i32) -> ChannelLayout { pub fn best(self, max: i32) -> ChannelLayout {

View File

@ -15,7 +15,7 @@ unsafe impl Sync for Codec {}
impl Codec { impl Codec {
pub unsafe fn wrap(ptr: *mut AVCodec) -> Self { pub unsafe fn wrap(ptr: *mut AVCodec) -> Self {
Codec { ptr: ptr } Codec { ptr }
} }
pub unsafe fn as_ptr(&self) -> *const AVCodec { pub unsafe fn as_ptr(&self) -> *const AVCodec {
@ -106,7 +106,7 @@ pub struct ProfileIter {
impl ProfileIter { impl ProfileIter {
pub fn new(id: Id, ptr: *const AVProfile) -> Self { pub fn new(id: Id, ptr: *const AVProfile) -> Self {
ProfileIter { id: id, ptr: ptr } ProfileIter { id, ptr }
} }
} }

View File

@ -18,10 +18,7 @@ unsafe impl Send for Context {}
impl Context { impl Context {
pub unsafe fn wrap(ptr: *mut AVCodecContext, owner: Option<Rc<dyn Drop>>) -> Self { pub unsafe fn wrap(ptr: *mut AVCodecContext, owner: Option<Rc<dyn Drop>>) -> Self {
Context { Context { ptr, owner }
ptr: ptr,
owner: owner,
}
} }
pub unsafe fn as_ptr(&self) -> *const AVCodecContext { pub unsafe fn as_ptr(&self) -> *const AVCodecContext {

View File

@ -18,10 +18,7 @@ impl<'a> Borrow<'a> {
packet.data = data.as_ptr() as *mut _; packet.data = data.as_ptr() as *mut _;
packet.size = data.len() as c_int; packet.size = data.len() as c_int;
Borrow { Borrow { packet, data }
packet: packet,
data: data,
}
} }
} }

View File

@ -282,7 +282,7 @@ pub struct SideDataIter<'a> {
impl<'a> SideDataIter<'a> { impl<'a> SideDataIter<'a> {
pub fn new(ptr: *const AVPacket) -> Self { pub fn new(ptr: *const AVPacket) -> Self {
SideDataIter { SideDataIter {
ptr: ptr, ptr,
cur: 0, cur: 0,
_marker: PhantomData, _marker: PhantomData,
} }

View File

@ -155,7 +155,7 @@ pub struct SideData<'a> {
impl<'a> SideData<'a> { impl<'a> SideData<'a> {
pub unsafe fn wrap(ptr: *mut AVPacketSideData) -> Self { pub unsafe fn wrap(ptr: *mut AVPacketSideData) -> Self {
SideData { SideData {
ptr: ptr, ptr,
_marker: PhantomData, _marker: PhantomData,
} }
} }

View File

@ -13,10 +13,7 @@ unsafe impl Send for Parameters {}
impl Parameters { impl Parameters {
pub unsafe fn wrap(ptr: *mut AVCodecParameters, owner: Option<Rc<dyn Drop>>) -> Self { pub unsafe fn wrap(ptr: *mut AVCodecParameters, owner: Option<Rc<dyn Drop>>) -> Self {
Parameters { Parameters { ptr, owner }
ptr: ptr,
owner: owner,
}
} }
pub unsafe fn as_ptr(&self) -> *const AVCodecParameters { pub unsafe fn as_ptr(&self) -> *const AVCodecParameters {

View File

@ -26,11 +26,11 @@ impl<'a> Picture<'a> {
height: u32, height: u32,
) -> Self { ) -> Self {
Picture { Picture {
ptr: ptr, ptr,
format: format, format,
width: width, width,
height: height, height,
_own: false, _own: false,
_marker: PhantomData, _marker: PhantomData,
@ -62,11 +62,11 @@ impl<'a> Picture<'a> {
match avpicture_alloc(ptr, format.into(), width as c_int, height as c_int) { match avpicture_alloc(ptr, format.into(), width as c_int, height as c_int) {
0 => Ok(Picture { 0 => Ok(Picture {
ptr: ptr, ptr,
format: format, format,
width: width, width,
height: height, height,
_own: true, _own: true,
_marker: PhantomData, _marker: PhantomData,

View File

@ -131,7 +131,7 @@ pub struct RectIter<'a> {
impl<'a> RectIter<'a> { impl<'a> RectIter<'a> {
pub fn new(ptr: *const AVSubtitle) -> Self { pub fn new(ptr: *const AVSubtitle) -> Self {
RectIter { RectIter {
ptr: ptr, ptr,
cur: 0, cur: 0,
_marker: PhantomData, _marker: PhantomData,
} }
@ -175,7 +175,7 @@ pub struct RectMutIter<'a> {
impl<'a> RectMutIter<'a> { impl<'a> RectMutIter<'a> {
pub fn new(ptr: *mut AVSubtitle) -> Self { pub fn new(ptr: *mut AVSubtitle) -> Self {
RectMutIter { RectMutIter {
ptr: ptr, ptr,
cur: 0, cur: 0,
_marker: PhantomData, _marker: PhantomData,
} }

View File

@ -55,7 +55,7 @@ pub struct Bitmap<'a> {
impl<'a> Bitmap<'a> { impl<'a> Bitmap<'a> {
pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self { pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self {
Bitmap { Bitmap {
ptr: ptr, ptr,
_marker: PhantomData, _marker: PhantomData,
} }
} }
@ -108,7 +108,7 @@ pub struct Text<'a> {
impl<'a> Text<'a> { impl<'a> Text<'a> {
pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self { pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self {
Text { Text {
ptr: ptr, ptr,
_marker: PhantomData, _marker: PhantomData,
} }
} }
@ -133,7 +133,7 @@ pub struct Ass<'a> {
impl<'a> Ass<'a> { impl<'a> Ass<'a> {
pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self { pub unsafe fn wrap(ptr: *const AVSubtitleRect) -> Self {
Ass { Ass {
ptr: ptr, ptr,
_marker: PhantomData, _marker: PhantomData,
} }
} }

View File

@ -11,7 +11,7 @@ pub struct Video {
impl Video { impl Video {
pub unsafe fn new(codec: Codec) -> Video { pub unsafe fn new(codec: Codec) -> Video {
Video { codec: codec } Video { codec }
} }
} }
@ -51,7 +51,7 @@ pub struct RateIter {
impl RateIter { impl RateIter {
pub fn new(ptr: *const AVRational) -> Self { pub fn new(ptr: *const AVRational) -> Self {
RateIter { ptr: ptr } RateIter { ptr }
} }
} }
@ -78,7 +78,7 @@ pub struct FormatIter {
impl FormatIter { impl FormatIter {
pub fn new(ptr: *const AVPixelFormat) -> Self { pub fn new(ptr: *const AVPixelFormat) -> Self {
FormatIter { ptr: ptr } FormatIter { ptr }
} }
} }

View File

@ -28,7 +28,7 @@ impl<'a> DeviceIter<'a> {
n if n < 0 => Err(Error::from(n)), n if n < 0 => Err(Error::from(n)),
_ => Ok(DeviceIter { _ => Ok(DeviceIter {
ptr: ptr, ptr,
cur: 0, cur: 0,
_marker: PhantomData, _marker: PhantomData,
}), }),

View File

@ -17,7 +17,7 @@ pub struct Info<'a> {
impl<'a> Info<'a> { impl<'a> Info<'a> {
pub unsafe fn wrap(ptr: *mut AVDeviceInfo) -> Self { pub unsafe fn wrap(ptr: *mut AVDeviceInfo) -> Self {
Info { Info {
ptr: ptr, ptr,
_marker: PhantomData, _marker: PhantomData,
} }
} }

View File

@ -14,7 +14,7 @@ pub struct Context<'a> {
impl<'a> Context<'a> { impl<'a> Context<'a> {
pub unsafe fn wrap(ptr: *mut AVFilterContext) -> Self { pub unsafe fn wrap(ptr: *mut AVFilterContext) -> Self {
Context { Context {
ptr: ptr, ptr,
_marker: PhantomData, _marker: PhantomData,
} }
} }

View File

@ -9,7 +9,7 @@ pub struct Sink<'a> {
impl<'a> Sink<'a> { impl<'a> Sink<'a> {
pub unsafe fn wrap<'b>(ctx: &'b mut Context<'b>) -> Sink<'b> { pub unsafe fn wrap<'b>(ctx: &'b mut Context<'b>) -> Sink<'b> {
Sink { ctx: ctx } Sink { ctx }
} }
} }

View File

@ -10,7 +10,7 @@ pub struct Source<'a> {
impl<'a> Source<'a> { impl<'a> Source<'a> {
pub unsafe fn wrap<'b>(ctx: &'b mut Context<'b>) -> Source<'b> { pub unsafe fn wrap<'b>(ctx: &'b mut Context<'b>) -> Source<'b> {
Source { ctx: ctx } Source { ctx }
} }
} }

View File

@ -11,7 +11,7 @@ pub struct Filter {
impl Filter { impl Filter {
pub unsafe fn wrap(ptr: *mut AVFilter) -> Self { pub unsafe fn wrap(ptr: *mut AVFilter) -> Self {
Filter { ptr: ptr } Filter { ptr }
} }
pub unsafe fn as_ptr(&self) -> *const AVFilter { pub unsafe fn as_ptr(&self) -> *const AVFilter {
@ -79,7 +79,7 @@ pub struct PadIter<'a> {
impl<'a> PadIter<'a> { impl<'a> PadIter<'a> {
pub fn new(ptr: *const AVFilterPad) -> Self { pub fn new(ptr: *const AVFilterPad) -> Self {
PadIter { PadIter {
ptr: ptr, ptr,
cur: 0, cur: 0,
_marker: PhantomData, _marker: PhantomData,
} }

View File

@ -16,7 +16,7 @@ unsafe impl Sync for Graph {}
impl Graph { impl Graph {
pub unsafe fn wrap(ptr: *mut AVFilterGraph) -> Self { pub unsafe fn wrap(ptr: *mut AVFilterGraph) -> Self {
Graph { ptr: ptr } Graph { ptr }
} }
pub unsafe fn as_ptr(&self) -> *const AVFilterGraph { pub unsafe fn as_ptr(&self) -> *const AVFilterGraph {
@ -136,7 +136,7 @@ pub struct Parser<'a> {
impl<'a> Parser<'a> { impl<'a> Parser<'a> {
pub fn new(graph: &mut Graph) -> Parser { pub fn new(graph: &mut Graph) -> Parser {
Parser { Parser {
graph: graph, graph,
inputs: ptr::null_mut(), inputs: ptr::null_mut(),
outputs: ptr::null_mut(), outputs: ptr::null_mut(),
} }

View File

@ -15,8 +15,8 @@ pub struct Pad<'a> {
impl<'a> Pad<'a> { impl<'a> Pad<'a> {
pub unsafe fn wrap(ptr: *const AVFilterPad, idx: isize) -> Self { pub unsafe fn wrap(ptr: *const AVFilterPad, idx: isize) -> Self {
Pad { Pad {
ptr: ptr, ptr,
idx: idx, idx,
_marker: PhantomData, _marker: PhantomData,
} }
} }

View File

@ -12,10 +12,7 @@ pub struct Chapter<'a> {
impl<'a> Chapter<'a> { impl<'a> Chapter<'a> {
pub unsafe fn wrap(context: &Context, index: usize) -> Chapter { pub unsafe fn wrap(context: &Context, index: usize) -> Chapter {
Chapter { Chapter { context, index }
context: context,
index: index,
}
} }
pub unsafe fn as_ptr(&self) -> *const AVChapter { pub unsafe fn as_ptr(&self) -> *const AVChapter {

View File

@ -19,7 +19,7 @@ impl<'a> ChapterMut<'a> {
pub unsafe fn wrap(context: &mut Context, index: usize) -> ChapterMut { pub unsafe fn wrap(context: &mut Context, index: usize) -> ChapterMut {
ChapterMut { ChapterMut {
context: mem::transmute_copy(&context), context: mem::transmute_copy(&context),
index: index, index,
immutable: Chapter::wrap(mem::transmute_copy(&context), index), immutable: Chapter::wrap(mem::transmute_copy(&context), index),
} }

View File

@ -17,7 +17,7 @@ unsafe impl Send for Context {}
impl Context { impl Context {
pub unsafe fn wrap(ptr: *mut AVFormatContext, mode: destructor::Mode) -> Self { pub unsafe fn wrap(ptr: *mut AVFormatContext, mode: destructor::Mode) -> Self {
Context { Context {
ptr: ptr, ptr,
dtor: Rc::new(Destructor::new(ptr, mode)), dtor: Rc::new(Destructor::new(ptr, mode)),
} }
} }
@ -131,7 +131,7 @@ pub struct Best<'a> {
impl<'a> Best<'a> { impl<'a> Best<'a> {
pub unsafe fn new<'b, 'c: 'b>(context: &'c Context) -> Best<'b> { pub unsafe fn new<'b, 'c: 'b>(context: &'c Context) -> Best<'b> {
Best { Best {
context: context, context,
wanted: -1, wanted: -1,
related: -1, related: -1,
@ -186,7 +186,7 @@ pub struct StreamIter<'a> {
impl<'a> StreamIter<'a> { impl<'a> StreamIter<'a> {
pub fn new<'s, 'c: 's>(context: &'c Context) -> StreamIter<'s> { pub fn new<'s, 'c: 's>(context: &'c Context) -> StreamIter<'s> {
StreamIter { StreamIter {
context: context, context,
current: 0, current: 0,
} }
} }
@ -254,7 +254,7 @@ pub struct StreamIterMut<'a> {
impl<'a> StreamIterMut<'a> { impl<'a> StreamIterMut<'a> {
pub fn new<'s, 'c: 's>(context: &'c mut Context) -> StreamIterMut<'s> { pub fn new<'s, 'c: 's>(context: &'c mut Context) -> StreamIterMut<'s> {
StreamIterMut { StreamIterMut {
context: context, context,
current: 0, current: 0,
} }
} }
@ -300,7 +300,7 @@ pub struct ChapterIter<'a> {
impl<'a> ChapterIter<'a> { impl<'a> ChapterIter<'a> {
pub fn new<'s, 'c: 's>(context: &'c Context) -> ChapterIter<'s> { pub fn new<'s, 'c: 's>(context: &'c Context) -> ChapterIter<'s> {
ChapterIter { ChapterIter {
context: context, context,
current: 0, current: 0,
} }
} }
@ -343,7 +343,7 @@ pub struct ChapterIterMut<'a> {
impl<'a> ChapterIterMut<'a> { impl<'a> ChapterIterMut<'a> {
pub fn new<'s, 'c: 's>(context: &'c mut Context) -> ChapterIterMut<'s> { pub fn new<'s, 'c: 's>(context: &'c mut Context) -> ChapterIterMut<'s> {
ChapterIterMut { ChapterIterMut {
context: context, context,
current: 0, current: 0,
} }
} }

View File

@ -13,10 +13,7 @@ pub struct Destructor {
impl Destructor { impl Destructor {
pub unsafe fn new(ptr: *mut AVFormatContext, mode: Mode) -> Self { pub unsafe fn new(ptr: *mut AVFormatContext, mode: Mode) -> Self {
Destructor { Destructor { ptr, mode }
ptr: ptr,
mode: mode,
}
} }
} }

View File

@ -19,7 +19,7 @@ unsafe impl Send for Input {}
impl Input { impl Input {
pub unsafe fn wrap(ptr: *mut AVFormatContext) -> Self { pub unsafe fn wrap(ptr: *mut AVFormatContext) -> Self {
Input { Input {
ptr: ptr, ptr,
ctx: Context::wrap(ptr, destructor::Mode::Input), ctx: Context::wrap(ptr, destructor::Mode::Input),
} }
} }
@ -149,7 +149,7 @@ pub struct PacketIter<'a> {
impl<'a> PacketIter<'a> { impl<'a> PacketIter<'a> {
pub fn new(context: &mut Input) -> PacketIter { pub fn new(context: &mut Input) -> PacketIter {
PacketIter { context: context } PacketIter { context }
} }
} }

View File

@ -21,7 +21,7 @@ unsafe impl Send for Output {}
impl Output { impl Output {
pub unsafe fn wrap(ptr: *mut AVFormatContext) -> Self { pub unsafe fn wrap(ptr: *mut AVFormatContext) -> Self {
Output { Output {
ptr: ptr, ptr,
ctx: Context::wrap(ptr, destructor::Mode::Output), ctx: Context::wrap(ptr, destructor::Mode::Output),
} }
} }

View File

@ -9,7 +9,7 @@ pub struct Input {
impl Input { impl Input {
pub unsafe fn wrap(ptr: *mut AVInputFormat) -> Self { pub unsafe fn wrap(ptr: *mut AVInputFormat) -> Self {
Input { ptr: ptr } Input { ptr }
} }
pub unsafe fn as_ptr(&self) -> *const AVInputFormat { pub unsafe fn as_ptr(&self) -> *const AVInputFormat {

View File

@ -14,7 +14,7 @@ pub struct Output {
impl Output { impl Output {
pub unsafe fn wrap(ptr: *mut AVOutputFormat) -> Self { pub unsafe fn wrap(ptr: *mut AVOutputFormat) -> Self {
Output { ptr: ptr } Output { ptr }
} }
pub unsafe fn as_ptr(&self) -> *const AVOutputFormat { pub unsafe fn as_ptr(&self) -> *const AVOutputFormat {

View File

@ -12,10 +12,7 @@ pub struct Stream<'a> {
impl<'a> Stream<'a> { impl<'a> Stream<'a> {
pub unsafe fn wrap(context: &Context, index: usize) -> Stream { pub unsafe fn wrap(context: &Context, index: usize) -> Stream {
Stream { Stream { context, index }
context: context,
index: index,
}
} }
pub unsafe fn as_ptr(&self) -> *const AVStream { pub unsafe fn as_ptr(&self) -> *const AVStream {
@ -98,10 +95,7 @@ pub struct SideDataIter<'a> {
impl<'a> SideDataIter<'a> { impl<'a> SideDataIter<'a> {
pub fn new<'sd, 's: 'sd>(stream: &'s Stream) -> SideDataIter<'sd> { pub fn new<'sd, 's: 'sd>(stream: &'s Stream) -> SideDataIter<'sd> {
SideDataIter { SideDataIter { stream, current: 0 }
stream: stream,
current: 0,
}
} }
} }

View File

@ -17,7 +17,7 @@ impl<'a> StreamMut<'a> {
pub unsafe fn wrap(context: &mut Context, index: usize) -> StreamMut { pub unsafe fn wrap(context: &mut Context, index: usize) -> StreamMut {
StreamMut { StreamMut {
context: mem::transmute_copy(&context), context: mem::transmute_copy(&context),
index: index, index,
immutable: Stream::wrap(mem::transmute_copy(&context), index), immutable: Stream::wrap(mem::transmute_copy(&context), index),
} }

View File

@ -60,7 +60,7 @@ impl Context {
e if e < 0 => Err(Error::from(e)), e if e < 0 => Err(Error::from(e)),
_ => Ok(Context { _ => Ok(Context {
ptr: ptr, ptr,
input: Definition { input: Definition {
format: src_format, format: src_format,

View File

@ -58,7 +58,7 @@ impl Context {
if !ptr.is_null() { if !ptr.is_null() {
Ok(Context { Ok(Context {
ptr: ptr, ptr,
input: Definition { input: Definition {
format: src_format, format: src_format,

View File

@ -14,7 +14,7 @@ pub struct Vector<'a> {
impl<'a> Vector<'a> { impl<'a> Vector<'a> {
pub unsafe fn wrap(ptr: *mut SwsVector) -> Self { pub unsafe fn wrap(ptr: *mut SwsVector) -> Self {
Vector { Vector {
ptr: ptr, ptr,
_own: false, _own: false,
_marker: PhantomData, _marker: PhantomData,
} }

View File

@ -15,7 +15,7 @@ pub struct Ref<'a> {
impl<'a> Ref<'a> { impl<'a> Ref<'a> {
pub unsafe fn wrap(ptr: *const AVDictionary) -> Self { pub unsafe fn wrap(ptr: *const AVDictionary) -> Self {
Ref { Ref {
ptr: ptr, ptr,
_marker: PhantomData, _marker: PhantomData,
} }
} }

View File

@ -15,7 +15,7 @@ pub struct Ref<'a> {
impl<'a> Ref<'a> { impl<'a> Ref<'a> {
pub unsafe fn wrap(ptr: *mut AVDictionary) -> Self { pub unsafe fn wrap(ptr: *mut AVDictionary) -> Self {
Ref { Ref {
ptr: ptr, ptr,
imm: immutable::Ref::wrap(ptr), imm: immutable::Ref::wrap(ptr),
_marker: PhantomData, _marker: PhantomData,
} }

View File

@ -153,10 +153,10 @@ impl Buffer {
pub fn new(format: Sample, channels: u16, samples: usize, align: bool) -> Self { pub fn new(format: Sample, channels: u16, samples: usize, align: bool) -> Self {
unsafe { unsafe {
let mut buf = Buffer { let mut buf = Buffer {
format: format, format,
channels: channels, channels,
samples: samples, samples,
align: align, align,
buffer: ptr::null_mut(), buffer: ptr::null_mut(),
size: 0, size: 0,

View File

@ -37,10 +37,7 @@ unsafe impl Sync for Frame {}
impl Frame { impl Frame {
#[inline(always)] #[inline(always)]
pub unsafe fn wrap(ptr: *mut AVFrame) -> Self { pub unsafe fn wrap(ptr: *mut AVFrame) -> Self {
Frame { Frame { ptr, _own: false }
ptr: ptr,
_own: false,
}
} }
#[inline(always)] #[inline(always)]

View File

@ -146,7 +146,7 @@ impl<'a> SideData<'a> {
#[inline(always)] #[inline(always)]
pub unsafe fn wrap(ptr: *mut AVFrameSideData) -> Self { pub unsafe fn wrap(ptr: *mut AVFrameSideData) -> Self {
SideData { SideData {
ptr: ptr, ptr,
_marker: PhantomData, _marker: PhantomData,
} }
} }