Fix all clippy warnings

Or silence the ones we don't care about.
This commit is contained in:
Sebastian Dröge 2018-07-20 10:21:06 +03:00
parent fc79b4c4c8
commit 694bcaa697
54 changed files with 272 additions and 231 deletions

View file

@ -74,7 +74,7 @@ fn get_request_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst
fn connect_rtpbin_srcpad(src_pad: &gst::Pad, sink: &gst::Element) -> Result<(), Error> {
let name = src_pad.get_name();
let split_name = name.split("_");
let split_name = name.split('_');
let split_name = split_name.collect::<Vec<&str>>();
let pt = split_name[5].parse::<u32>()?;
@ -248,7 +248,7 @@ fn example_main() -> Result<(), Error> {
return Err(ErrorMessage {
src: msg.get_src()
.map(|s| s.get_path_string())
.unwrap_or(String::from("None")),
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
cause: err.get_error(),

View file

@ -186,7 +186,7 @@ fn example_main() -> Result<(), Error> {
return Err(ErrorMessage {
src: msg.get_src()
.map(|s| s.get_path_string())
.unwrap_or(String::from("None")),
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
cause: err.get_error(),

View file

@ -42,7 +42,7 @@ fn main_loop() -> Result<(), Error> {
let factory = RTSPMediaFactory::new();
let mounts = server.get_mount_points().ok_or(NoMountPoints)?;
let auth = RTSPAuth::new();
let mut token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"user")]);
let token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"user")]);
let basic = RTSPAuth::make_basic("user", "password");
let cert = gio::TlsCertificate::new_from_pem(
"-----BEGIN CERTIFICATE-----\
@ -86,7 +86,7 @@ fn main_loop() -> Result<(), Error> {
}
auth.set_tls_certificate(&cert);
auth.add_basic(basic.as_str(), &mut token);
auth.add_basic(basic.as_str(), &token);
server.set_auth(&auth);
factory.set_launch(args[1].as_str());
factory.set_transport_mode(RTSPTransportMode::RECORD);

View file

@ -53,7 +53,7 @@ fn example_main() -> Result<(), Error> {
let tagsetter = pipeline
.get_by_interface(gst::TagSetter::static_type())
.ok_or(failure::err_msg("No TagSetter found"))?;
.ok_or_else(|| failure::err_msg("No TagSetter found"))?;
let tagsetter = tagsetter
.dynamic_cast::<gst::TagSetter>()
.map_err(|_| failure::err_msg("No TagSetter found"))?;

View file

@ -15,6 +15,7 @@ use std::cell::RefCell;
use std::ptr;
use AppSink;
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
pub struct AppSinkCallbacks {
eos: Option<RefCell<Box<FnMut(&AppSink) + Send + 'static>>>,
new_preroll: Option<RefCell<Box<FnMut(&AppSink) -> gst::FlowReturn + Send + 'static>>>,
@ -36,6 +37,7 @@ impl AppSinkCallbacks {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
pub struct AppSinkCallbacksBuilder {
eos: Option<RefCell<Box<FnMut(&AppSink) + Send + 'static>>>,
new_preroll: Option<RefCell<Box<FnMut(&AppSink) -> gst::FlowReturn + Send + 'static>>>,
@ -105,10 +107,9 @@ impl AppSinkCallbacksBuilder {
unsafe extern "C" fn trampoline_eos(appsink: *mut ffi::GstAppSink, callbacks: gpointer) {
let callbacks = &*(callbacks as *const AppSinkCallbacks);
callbacks
.eos
.as_ref()
.map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsink)));
if let Some(ref eos) = callbacks.eos {
(&mut *eos.borrow_mut())(&from_glib_borrow(appsink))
}
}
unsafe extern "C" fn trampoline_new_preroll(
@ -117,12 +118,13 @@ unsafe extern "C" fn trampoline_new_preroll(
) -> gst_ffi::GstFlowReturn {
let callbacks = &*(callbacks as *const AppSinkCallbacks);
callbacks
.new_preroll
.as_ref()
.map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsink)))
.unwrap_or(gst::FlowReturn::Error)
.to_glib()
let ret = if let Some(ref new_preroll) = callbacks.new_preroll {
(&mut *new_preroll.borrow_mut())(&from_glib_borrow(appsink))
} else {
gst::FlowReturn::Error
};
ret.to_glib()
}
unsafe extern "C" fn trampoline_new_sample(
@ -131,12 +133,13 @@ unsafe extern "C" fn trampoline_new_sample(
) -> gst_ffi::GstFlowReturn {
let callbacks = &*(callbacks as *const AppSinkCallbacks);
callbacks
.new_sample
.as_ref()
.map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsink)))
.unwrap_or(gst::FlowReturn::Error)
.to_glib()
let ret = if let Some(ref new_sample) = callbacks.new_sample {
(&mut *new_sample.borrow_mut())(&from_glib_borrow(appsink))
} else {
gst::FlowReturn::Error
};
ret.to_glib()
}
unsafe extern "C" fn destroy_callbacks(ptr: gpointer) {

View file

@ -15,6 +15,7 @@ use std::mem;
use std::ptr;
use AppSrc;
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
pub struct AppSrcCallbacks {
need_data: Option<RefCell<Box<FnMut(&AppSrc, u32) + Send + 'static>>>,
enough_data: Option<Box<Fn(&AppSrc) + Send + Sync + 'static>>,
@ -37,6 +38,7 @@ impl AppSrcCallbacks {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
pub struct AppSrcCallbacksBuilder {
need_data: Option<RefCell<Box<FnMut(&AppSrc, u32) + Send + 'static>>>,
enough_data: Option<Box<Fn(&AppSrc) + Send + Sync + 'static>>,
@ -111,19 +113,17 @@ unsafe extern "C" fn trampoline_need_data(
) {
let callbacks = &*(callbacks as *const AppSrcCallbacks);
callbacks
.need_data
.as_ref()
.map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsrc), length));
if let Some(ref need_data) = callbacks.need_data {
(&mut *need_data.borrow_mut())(&from_glib_borrow(appsrc), length);
}
}
unsafe extern "C" fn trampoline_enough_data(appsrc: *mut ffi::GstAppSrc, callbacks: gpointer) {
let callbacks = &*(callbacks as *const AppSrcCallbacks);
callbacks
.enough_data
.as_ref()
.map(|f| f(&from_glib_borrow(appsrc)));
if let Some(ref enough_data) = callbacks.enough_data {
(*enough_data)(&from_glib_borrow(appsrc));
}
}
unsafe extern "C" fn trampoline_seek_data(
@ -133,12 +133,13 @@ unsafe extern "C" fn trampoline_seek_data(
) -> gboolean {
let callbacks = &*(callbacks as *const AppSrcCallbacks);
callbacks
.seek_data
.as_ref()
.map(|f| f(&from_glib_borrow(appsrc), offset))
.unwrap_or(false)
.to_glib()
let ret = if let Some(ref seek_data) = callbacks.seek_data {
(*seek_data)(&from_glib_borrow(appsrc), offset)
} else {
false
};
ret.to_glib()
}
unsafe extern "C" fn destroy_callbacks(ptr: gpointer) {

View file

@ -19,7 +19,7 @@ use gst::MiniObject;
use array_init;
impl AudioChannelPosition {
pub fn to_mask(&self) -> u64 {
pub fn to_mask(self) -> u64 {
unsafe {
let val = mem::transmute::<ffi::GstAudioChannelPosition, u32>(self.to_glib());
1 << val

View file

@ -39,8 +39,8 @@ impl ::AudioFormat {
unsafe { from_glib(ffi::gst_audio_format_from_string(s.to_glib_none().0)) }
}
pub fn to_string<'a>(&self) -> &'a str {
if *self == ::AudioFormat::Unknown {
pub fn to_string<'a>(self) -> &'a str {
if self == ::AudioFormat::Unknown {
return "UNKNOWN";
}
@ -69,7 +69,7 @@ impl str::FromStr for ::AudioFormat {
impl fmt::Display for ::AudioFormat {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.write_str(self.to_string())
f.write_str(self.to_string().as_str())
}
}

View file

@ -131,13 +131,14 @@ impl<'a> AudioInfoBuilder<'a> {
}
impl AudioInfo {
#[cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))]
pub fn new<'a>(format: ::AudioFormat, rate: u32, channels: u32) -> AudioInfoBuilder<'a> {
assert_initialized_main_thread!();
AudioInfoBuilder {
format: format,
rate: rate,
channels: channels,
format,
rate,
channels,
positions: None,
flags: None,
layout: None,

View file

@ -20,7 +20,7 @@ glib_wrapper! {
match fn {
ref => |ptr| {
gobject_ffi::g_boxed_copy(ffi::gst_flow_combiner_get_type(), ptr as *mut _) as *mut ffi::GstFlowCombiner
gobject_ffi::g_boxed_copy(ffi::gst_flow_combiner_get_type(), ptr as *mut _)
},
unref => |ptr| {
gobject_ffi::g_boxed_free(ffi::gst_flow_combiner_get_type(), ptr as *mut _)

View file

@ -29,6 +29,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
mod auto;
pub use auto::functions::*;
pub use auto::*;

View file

@ -12,6 +12,7 @@ use glib_ffi;
pub struct MutexGuard<'a>(&'a glib_ffi::GMutex);
impl<'a> MutexGuard<'a> {
#[cfg_attr(feature = "cargo-clippy", allow(trivially_copy_pass_by_ref))]
pub fn lock(mutex: &'a glib_ffi::GMutex) -> Self {
unsafe {
glib_ffi::g_mutex_lock(mut_override(mutex));

View file

@ -71,6 +71,7 @@ unsafe extern "C" fn notify_timeout_trampoline<P>(
) where
P: IsA<Discoverer>,
{
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&Discoverer::from_glib_borrow(this).downcast_unchecked())
}

View file

@ -20,8 +20,8 @@ impl Iterator for Iter {
fn next(&mut self) -> Option<DiscovererStreamInfo> {
let current = self.stream_info.take();
self.stream_info = match &current {
&Some(ref c) => {
self.stream_info = match current {
Some(ref c) => {
// Decide on the direction
if self.direction_forward {
c.get_next()
@ -29,7 +29,7 @@ impl Iterator for Iter {
c.get_previous()
}
}
&None => None,
None => None,
};
current
}

View file

@ -43,6 +43,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
mod auto;
pub use auto::*;

View file

@ -105,6 +105,7 @@ unsafe extern "C" fn duration_changed_trampoline(
object: u64,
f: glib_ffi::gpointer,
) {
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&Player, gst::ClockTime) + Send + 'static) = transmute(f);
f(&from_glib_borrow(this), gst::ClockTime(Some(object)))
}
@ -114,6 +115,7 @@ unsafe extern "C" fn position_updated_trampoline(
object: u64,
f: glib_ffi::gpointer,
) {
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&Player, gst::ClockTime) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this), gst::ClockTime(Some(object)))
}
@ -123,6 +125,7 @@ unsafe extern "C" fn seek_done_trampoline(
object: u64,
f: glib_ffi::gpointer,
) {
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&Player, gst::ClockTime) + Send + 'static) = transmute(f);
f(&from_glib_borrow(this), gst::ClockTime(Some(object)))
}

View file

@ -45,6 +45,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
mod auto;
pub use auto::*;

View file

@ -27,10 +27,11 @@ impl GstRcRTSPTokenExt<RTSPTokenRef> for GstRc<RTSPTokenRef> {
}
fn new(values: &[(&str, &ToSendValue)]) -> Self {
let token = RTSPToken::new_empty();
let mut token = RTSPToken::new_empty();
{
let structure = token.writable_structure().unwrap();
let token = token.get_mut().unwrap();
let structure = token.get_mut_structure().unwrap();
for &(f, v) in values {
structure.set_value(f, v.to_send_value());
@ -64,7 +65,7 @@ impl RTSPTokenRef {
}
}
pub fn writable_structure(&self) -> Option<&mut gst::StructureRef> {
pub fn get_mut_structure(&mut self) -> Option<&mut gst::StructureRef> {
unsafe {
let structure = ffi::gst_rtsp_token_writable_structure(self.as_mut_ptr());
if structure.is_null() {

View file

@ -35,7 +35,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(non_snake_case))]
#[allow(non_snake_case)]
mod auto;
pub use auto::*;

View file

@ -14,9 +14,9 @@ pub struct MIKEYMapSRTP(ffi::GstMIKEYMapSRTP);
impl MIKEYMapSRTP {
pub fn new(policy: u8, ssrc: u32, roc: u32) -> MIKEYMapSRTP {
MIKEYMapSRTP(ffi::GstMIKEYMapSRTP {
policy: policy,
ssrc: ssrc,
roc: roc,
policy,
ssrc,
roc,
})
}

View file

@ -22,6 +22,10 @@ impl MIKEYPayloadSPParam {
self.0.len
}
pub fn is_empty(&self) -> bool {
self.0.len == 0
}
pub fn val(&self) -> &[u8] {
unsafe { slice::from_raw_parts(self.0.val as *const u8, self.0.len as usize) }
}

View file

@ -508,7 +508,6 @@ impl SDPMedia {
media.to_glib_none_mut().0,
)
};
mem::forget(media);
match result {
ffi::GST_SDP_OK => Ok(()),
_ => Err(()),

View file

@ -709,12 +709,12 @@ impl SDPMessage {
unsafe { ffi::gst_sdp_message_zones_len(self.to_glib_none().0) }
}
pub fn as_uri(scheme: &str, msg: &SDPMessage) -> Option<String> {
pub fn as_uri(&self, scheme: &str) -> Option<String> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_sdp_message_as_uri(
scheme.to_glib_none().0,
msg.to_glib_none().0,
self.to_glib_none().0,
))
}
}
@ -753,4 +753,10 @@ impl SDPMessage {
}
}
impl Default for SDPMessage {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for SDPMessage {}

View file

@ -43,6 +43,7 @@ impl SDPTime {
}
pub fn repeat(&self) -> Vec<&str> {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe {
let arr = (*self.0.repeat).data as *const *const c_char;
let len = (*self.0.repeat).len as usize;

View file

@ -54,6 +54,7 @@ pub fn convert_sample_async<F>(
) where
F: FnOnce(Result<gst::Sample, glib::Error>) + Send + 'static,
{
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let callback: &mut Option<Box<F>> = mem::transmute(user_data);
let callback = callback.take().unwrap();

View file

@ -105,35 +105,35 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> {
pub fn timestamp(self, timestamp: gst::ClockTime) -> Self {
Self {
timestamp: timestamp,
timestamp,
..self
}
}
pub fn stream_time(self, stream_time: gst::ClockTime) -> Self {
Self {
stream_time: stream_time,
stream_time,
..self
}
}
pub fn running_time(self, running_time: gst::ClockTime) -> Self {
Self {
running_time: running_time,
running_time,
..self
}
}
pub fn all_headers(self, all_headers: bool) -> Self {
Self {
all_headers: all_headers,
all_headers,
..self
}
}
pub fn count(self, count: u32) -> Self {
Self {
count: count,
count,
..self
}
}
@ -182,7 +182,7 @@ pub fn parse_downstream_force_key_unit_event(
stream_time: from_glib(stream_time),
running_time: from_glib(running_time),
all_headers: from_glib(all_headers),
count: count,
count,
})
} else {
None
@ -218,21 +218,21 @@ impl<'a> UpstreamForceKeyUnitEventBuilder<'a> {
pub fn running_time(self, running_time: gst::ClockTime) -> Self {
Self {
running_time: running_time,
running_time,
..self
}
}
pub fn all_headers(self, all_headers: bool) -> Self {
Self {
all_headers: all_headers,
all_headers,
..self
}
}
pub fn count(self, count: u32) -> Self {
Self {
count: count,
count,
..self
}
}
@ -271,7 +271,7 @@ pub fn parse_upstream_force_key_unit_event(
Some(UpstreamForceKeyUnitEvent {
running_time: from_glib(running_time),
all_headers: from_glib(all_headers),
count: count,
count,
})
} else {
None
@ -311,7 +311,7 @@ impl<'a> StillFrameEventBuilder<'a> {
seqnum: None,
running_time_offset: None,
other_fields: Vec::new(),
in_still: in_still,
in_still,
}
}

View file

@ -82,8 +82,8 @@ impl ::VideoFormat {
}
}
pub fn to_string<'a>(&self) -> &'a str {
if *self == ::VideoFormat::Unknown {
pub fn to_string<'a>(self) -> &'a str {
if self == ::VideoFormat::Unknown {
return "UNKNOWN";
}
@ -112,6 +112,6 @@ impl str::FromStr for ::VideoFormat {
impl fmt::Display for ::VideoFormat {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.write_str(self.to_string())
f.write_str(self.to_string().as_str())
}
}

View file

@ -179,7 +179,7 @@ impl VideoFrame<Readable> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ,
));
if !res {
@ -205,7 +205,7 @@ impl VideoFrame<Readable> {
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
id,
mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ,
));
if !res {
@ -237,10 +237,8 @@ impl VideoFrame<Writable> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
),
));
if !res {
@ -266,10 +264,8 @@ impl VideoFrame<Writable> {
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
id,
mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
),
));
if !res {
@ -337,7 +333,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ,
));
if !res {
@ -363,7 +359,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
id,
mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ,
));
if !res {
@ -515,10 +511,8 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
),
));
if !res {
@ -544,10 +538,8 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
id,
mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
),
));
if !res {
@ -598,8 +590,7 @@ impl<'a> ops::Deref for VideoFrameRef<&'a mut gst::BufferRef> {
type Target = VideoFrameRef<&'a gst::BufferRef>;
fn deref(&self) -> &Self::Target {
use std::mem;
unsafe { mem::transmute(self) }
unsafe { &*(self as *const VideoFrameRef<&'a mut gst::BufferRef> as *const VideoFrameRef<&'a gst::BufferRef>) }
}
}

View file

@ -251,7 +251,7 @@ impl<'a> VideoInfoBuilder<'a> {
self.height,
);
if info.finfo.is_null() || info.width <= 0 || info.width <= 0 {
if info.finfo.is_null() || info.width <= 0 || info.height <= 0 {
return None;
}
@ -423,6 +423,7 @@ impl<'a> VideoInfoBuilder<'a> {
}
impl VideoInfo {
#[cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))]
pub fn new<'a>(format: ::VideoFormat, width: u32, height: u32) -> VideoInfoBuilder<'a> {
assert_initialized_main_thread!();
@ -449,9 +450,9 @@ impl VideoInfo {
#[cfg(any(feature = "v1_12", feature = "dox"))]
{
VideoInfoBuilder {
format: format,
width: width,
height: height,
format,
width,
height,
interlace_mode: None,
flags: None,
size: None,
@ -736,7 +737,7 @@ impl glib::translate::FromGlibPtrFull<*mut ffi::GstVideoInfo> for VideoInfo {
#[cfg(any(feature = "v1_12", feature = "dox"))]
impl ::VideoFieldOrder {
pub fn to_string(&self) -> String {
pub fn to_string(self) -> String {
unsafe { from_glib_full(ffi::gst_video_field_order_to_string(self.to_glib())) }
}
@ -765,7 +766,7 @@ impl fmt::Display for ::VideoFieldOrder {
}
impl ::VideoInterlaceMode {
pub fn to_string(&self) -> String {
pub fn to_string(self) -> String {
unsafe { from_glib_full(ffi::gst_video_interlace_mode_to_string(self.to_glib())) }
}

View file

@ -127,7 +127,7 @@ impl GstRc<BufferRef> {
if res {
Ok(MappedBuffer {
buffer: Some(self),
map_info: map_info,
map_info,
phantom: PhantomData,
})
} else {
@ -147,7 +147,7 @@ impl GstRc<BufferRef> {
if res {
Ok(MappedBuffer {
buffer: Some(self),
map_info: map_info,
map_info,
phantom: PhantomData,
})
} else {
@ -175,7 +175,7 @@ impl BufferRef {
if res == glib_ffi::GTRUE {
Some(BufferMap {
buffer: self,
map_info: map_info,
map_info,
phantom: PhantomData,
})
} else {
@ -191,7 +191,7 @@ impl BufferRef {
if res == glib_ffi::GTRUE {
Some(BufferMap {
buffer: self,
map_info: map_info,
map_info,
phantom: PhantomData,
})
} else {

View file

@ -105,6 +105,7 @@ impl ToOwned for BufferListRef {
type Owned = GstRc<BufferListRef>;
fn to_owned(&self) -> GstRc<BufferListRef> {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) }
}
}
@ -145,7 +146,7 @@ impl<'a> Iter<'a> {
fn new(list: &'a BufferListRef) -> Iter<'a> {
skip_assert_initialized!();
Iter {
list: list,
list,
idx: 0,
size: list.len() as u32,
}

View file

@ -65,6 +65,7 @@ impl ClockTime {
}
impl fmt::Display for ClockTime {
#[cfg_attr(feature = "cargo-clippy", allow(many_single_char_names))]
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let precision = f.precision().unwrap_or(9);
// TODO: Could also check width and pad the hours as needed

View file

@ -90,6 +90,7 @@ impl ToOwned for ContextRef {
type Owned = GstRc<ContextRef>;
fn to_owned(&self) -> GstRc<ContextRef> {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) }
}
}

View file

@ -100,6 +100,7 @@ pub trait ElementExtManual {
fn get_pad_template(&self, name: &str) -> Option<PadTemplate>;
fn get_pad_template_list(&self) -> Vec<PadTemplate>;
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
fn message_full<T: ::MessageErrorDomain>(
&self,
type_: ElementMessageType,
@ -110,7 +111,9 @@ pub trait ElementExtManual {
function: &str,
line: u32,
);
#[cfg(any(feature = "v1_10", feature = "dox"))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
fn message_full_with_details<T: ::MessageErrorDomain>(
&self,
type_: ElementMessageType,

View file

@ -75,19 +75,19 @@ impl ErrorMessage {
function: &'static str,
line: u32,
) -> ErrorMessage {
let domain = T::domain();
let code = error.code();
let error_domain = T::domain();
let error_code = error.code();
let message = message.into();
let debug = debug.into();
ErrorMessage {
error_domain: domain,
error_code: code,
error_domain,
error_code,
message: message.map(String::from),
debug: debug.map(String::from),
filename: filename,
function: function,
line: line,
filename,
function,
line,
}
}
}

View file

@ -102,23 +102,23 @@ unsafe impl MiniObject for EventRef {
}
impl EventType {
pub fn is_upstream(&self) -> bool {
pub fn is_upstream(self) -> bool {
(self.to_glib() as u32) & ffi::GST_EVENT_TYPE_UPSTREAM != 0
}
pub fn is_downstream(&self) -> bool {
pub fn is_downstream(self) -> bool {
(self.to_glib() as u32) & ffi::GST_EVENT_TYPE_DOWNSTREAM != 0
}
pub fn is_serialized(&self) -> bool {
pub fn is_serialized(self) -> bool {
(self.to_glib() as u32) & ffi::GST_EVENT_TYPE_SERIALIZED != 0
}
pub fn is_sticky(&self) -> bool {
pub fn is_sticky(self) -> bool {
(self.to_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY != 0
}
pub fn is_sticky_multi(&self) -> bool {
pub fn is_sticky_multi(self) -> bool {
(self.to_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY_MULTI != 0
}
}
@ -914,6 +914,7 @@ impl<'a> EventBuilder<'a> {
macro_rules! event_builder_generic_impl {
($new_fn:expr) => {
#[cfg_attr(feature = "cargo-clippy", allow(needless_update))]
pub fn seqnum(self, seqnum: Seqnum) -> Self {
Self {
builder: self.builder.seqnum(seqnum),
@ -921,6 +922,7 @@ macro_rules! event_builder_generic_impl {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(needless_update))]
pub fn running_time_offset(self, running_time_offset: i64) -> Self {
Self {
builder: self.builder.running_time_offset(running_time_offset),
@ -928,6 +930,7 @@ macro_rules! event_builder_generic_impl {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(needless_update))]
pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
Self {
builder: self.builder.other_fields(other_fields),
@ -986,7 +989,7 @@ impl<'a> FlushStopBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
reset_time: reset_time,
reset_time,
}
}
@ -1004,7 +1007,7 @@ impl<'a> StreamStartBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
stream_id: stream_id,
stream_id,
flags: None,
group_id: None,
}
@ -1045,7 +1048,7 @@ impl<'a> CapsBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
caps: caps,
caps,
}
}
@ -1061,7 +1064,7 @@ impl<'a> SegmentBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
segment: segment,
segment,
}
}
@ -1079,7 +1082,7 @@ impl<'a> StreamCollectionBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
stream_collection: stream_collection,
stream_collection,
}
}
@ -1118,9 +1121,9 @@ impl<'a> BufferSizeBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
minsize: minsize,
maxsize: maxsize,
async: async,
minsize,
maxsize,
async,
}
}
@ -1142,8 +1145,8 @@ impl<'a> SinkMessageBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
name: name,
msg: msg,
name,
msg,
}
}
@ -1164,7 +1167,7 @@ impl<'a> StreamGroupDoneBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
group_id: group_id,
group_id,
}
}
@ -1197,8 +1200,8 @@ impl<'a> TocBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
toc: toc,
updated: updated,
toc,
updated,
}
}
@ -1219,8 +1222,8 @@ impl<'a> ProtectionBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
system_id: system_id,
data: data,
system_id,
data,
origin: None,
}
}
@ -1248,7 +1251,7 @@ impl<'a> SegmentDoneBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
position: position,
position,
}
}
@ -1268,8 +1271,8 @@ impl<'a> GapBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
timestamp: timestamp,
duration: duration,
timestamp,
duration,
}
}
@ -1291,10 +1294,10 @@ impl<'a> QosBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
type_: type_,
proportion: proportion,
diff: diff,
timestamp: timestamp,
type_,
proportion,
diff,
timestamp,
}
}
@ -1327,8 +1330,8 @@ impl<'a> SeekBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
rate: rate,
flags: flags,
rate,
flags,
start_type,
start,
stop_type,
@ -1378,7 +1381,7 @@ impl<'a> LatencyBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
latency: latency,
latency,
}
}
@ -1397,10 +1400,10 @@ impl<'a> StepBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
amount: amount,
rate: rate,
flush: flush,
intermediate: intermediate,
amount,
rate,
flush,
intermediate,
}
}
@ -1436,7 +1439,7 @@ impl<'a> TocSelectBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
uid: uid,
uid,
}
}
@ -1454,7 +1457,7 @@ impl<'a> SelectStreamsBuilder<'a> {
skip_assert_initialized!();
Self {
builder: EventBuilder::new(),
streams: streams,
streams,
}
}

View file

@ -144,7 +144,7 @@ impl GenericFormattedValue {
GenericFormattedValue::Bytes(v) => v.map(|v| v as i64).unwrap_or(-1),
GenericFormattedValue::Time(v) => v.map(|v| v as i64).unwrap_or(-1),
GenericFormattedValue::Buffers(v) => v.map(|v| v as i64).unwrap_or(-1),
GenericFormattedValue::Percent(v) => v.map(|v| v as i64).unwrap_or(-1),
GenericFormattedValue::Percent(v) => v.map(i64::from).unwrap_or(-1),
GenericFormattedValue::Other(_, v) => v,
}
}

View file

@ -319,7 +319,7 @@ where
fn new(items: Vec<T>) -> Self {
Self {
pos: 0,
items: items,
items,
}
}
}

View file

@ -9,7 +9,6 @@
use libc::c_char;
use std::ffi::CStr;
use std::fmt;
use std::mem;
use std::ptr;
use ffi;
@ -18,9 +17,11 @@ use gobject_ffi;
use glib::translate::{from_glib, ToGlib, ToGlibPtr};
use glib::IsA;
#[derive(PartialEq, Eq, Clone, Copy)]
pub struct DebugCategory(ptr::NonNull<ffi::GstDebugCategory>);
#[cfg_attr(feature = "cargo-clippy", allow(trivially_copy_pass_by_ref))]
impl DebugCategory {
pub fn new<'a, P: Into<Option<&'a str>>>(
name: &str,
@ -78,9 +79,9 @@ impl DebugCategory {
pub fn get_color(&self) -> ::DebugColorFlags {
unsafe {
from_glib(mem::transmute::<u32, ffi::GstDebugColorFlags>(
from_glib(
ffi::gst_debug_category_get_color(self.0.as_ptr()),
))
)
}
}

View file

@ -1206,6 +1206,7 @@ impl<'a> MessageBuilder<'a> {
macro_rules! message_builder_generic_impl {
($new_fn:expr) => {
#[cfg_attr(feature = "cargo-clippy", allow(needless_update))]
pub fn src<O: IsA<Object> + Cast + Clone>(self, src: Option<&O>) -> Self {
Self {
builder: self.builder.src(src),
@ -1213,6 +1214,7 @@ macro_rules! message_builder_generic_impl {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(needless_update))]
pub fn seqnum(self, seqnum: Seqnum) -> Self {
Self {
builder: self.builder.seqnum(seqnum),
@ -1221,6 +1223,7 @@ macro_rules! message_builder_generic_impl {
}
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "cargo-clippy", allow(needless_update))]
pub fn other_fields(self, other_fields: &[(&'a str, &'a ToSendValue)]) -> Self {
Self {
builder: self.builder.other_fields(other_fields),
@ -1292,8 +1295,8 @@ impl<'a, T: MessageErrorDomain> ErrorBuilder<'a, T> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
error: error,
message: message,
error,
message,
debug: None,
details: None,
}
@ -1357,8 +1360,8 @@ impl<'a, T: MessageErrorDomain> WarningBuilder<'a, T> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
error: error,
message: message,
error,
message,
debug: None,
details: None,
}
@ -1422,8 +1425,8 @@ impl<'a, T: MessageErrorDomain> InfoBuilder<'a, T> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
error: error,
message: message,
error,
message,
debug: None,
details: None,
}
@ -1483,7 +1486,7 @@ impl<'a> TagBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
tags: tags,
tags,
}
}
@ -1503,7 +1506,7 @@ impl<'a> BufferingBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
percent: percent,
percent,
stats: None,
}
}
@ -1550,9 +1553,9 @@ impl<'a> StateChangedBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
old: old,
new: new,
pending: pending,
old,
new,
pending,
}
}
@ -1600,12 +1603,12 @@ impl<'a> StepDoneBuilder<'a> {
assert_eq!(amount.get_format(), duration.get_format());
Self {
builder: MessageBuilder::new(),
amount: amount,
rate: rate,
flush: flush,
intermediate: intermediate,
duration: duration,
eos: eos,
amount,
rate,
flush,
intermediate,
duration,
eos,
}
}
@ -1631,8 +1634,8 @@ impl<'a> ClockProvideBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
clock: clock,
ready: ready,
clock,
ready,
}
}
@ -1652,7 +1655,7 @@ impl<'a> ClockLostBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
clock: clock,
clock,
}
}
@ -1671,7 +1674,7 @@ impl<'a> NewClockBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
clock: clock,
clock,
}
}
@ -1692,9 +1695,9 @@ impl<'a> StructureChangeBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
type_: type_,
owner: owner,
busy: busy,
type_,
owner,
busy,
}
}
@ -1717,8 +1720,8 @@ impl<'a> StreamStatusBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
type_: type_,
owner: owner,
type_,
owner,
status_object: None,
}
}
@ -1790,7 +1793,7 @@ impl<'a> SegmentStartBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
position: position,
position,
}
}
@ -1810,7 +1813,7 @@ impl<'a> SegmentDoneBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
position: position,
position,
}
}
@ -1872,7 +1875,7 @@ impl<'a> AsyncDoneBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
running_time: running_time,
running_time,
}
}
@ -1891,7 +1894,7 @@ impl<'a> RequestStateBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
state: state,
state,
}
}
@ -1920,11 +1923,11 @@ impl<'a> StepStartBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
active: active,
amount: amount,
rate: rate,
flush: flush,
intermediate: intermediate,
active,
amount,
rate,
flush,
intermediate,
}
}
@ -1960,11 +1963,11 @@ impl<'a> QosBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
live: live,
running_time: running_time,
stream_time: stream_time,
timestamp: timestamp,
duration: duration,
live,
running_time,
stream_time,
timestamp,
duration,
values: None,
stats: None,
}
@ -2022,9 +2025,9 @@ impl<'a> ProgressBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
type_: type_,
code: code,
text: text,
type_,
code,
text,
}
}
@ -2046,8 +2049,8 @@ impl<'a> TocBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
toc: toc,
updated: updated,
toc,
updated,
}
}
@ -2067,7 +2070,7 @@ impl<'a> ResetTimeBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
running_time: running_time,
running_time,
}
}
@ -2115,7 +2118,7 @@ impl<'a> NeedContextBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
context_type: context_type,
context_type,
}
}
@ -2153,7 +2156,7 @@ impl<'a> DeviceAddedBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
device: device,
device,
}
}
@ -2172,7 +2175,7 @@ impl<'a> DeviceRemovedBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
device: device,
device,
}
}
@ -2194,7 +2197,7 @@ impl<'a> PropertyNotifyBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
property_name: property_name,
property_name,
value: None,
}
}
@ -2231,7 +2234,7 @@ impl<'a> StreamCollectionBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
collection: collection,
collection,
}
}
@ -2255,7 +2258,7 @@ impl<'a> StreamsSelectedBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
collection: collection,
collection,
streams: None,
}
}
@ -2293,7 +2296,7 @@ impl<'a> RedirectBuilder<'a> {
skip_assert_initialized!();
Self {
builder: MessageBuilder::new(),
location: location,
location,
tag_list: None,
entry_struct: None,
entries: None,

View file

@ -432,6 +432,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
where
F: Fn(&Pad, &Option<::Object>) -> bool + Send + Sync + 'static,
{
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
unsafe {
let func_box: Box<
Fn(&Pad, &Option<::Object>) -> bool + Send + Sync + 'static,
@ -449,6 +450,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
where
F: Fn(&Pad, &Option<::Object>, ::PadMode, bool) -> bool + Send + Sync + 'static,
{
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
unsafe {
let func_box: Box<
Fn(&Pad, &Option<::Object>, ::PadMode, bool) -> bool + Send + Sync + 'static,

View file

@ -20,7 +20,7 @@ glib_wrapper! {
pub struct Promise(Shared<ffi::GstPromise>);
match fn {
ref => |ptr| ffi::gst_mini_object_ref(ptr as *mut _) as *mut ffi::GstPromise,
ref => |ptr| ffi::gst_mini_object_ref(ptr as *mut _),
unref => |ptr| ffi::gst_mini_object_unref(ptr as *mut _),
get_type => || ffi::gst_promise_get_type(),
}

View file

@ -304,7 +304,7 @@ macro_rules! declare_concrete_query(
fn deref(&self) -> &Self::Target {
unsafe {
mem::transmute(self)
&*(self as *const $name<&'a mut QueryRef> as *const $name<&'a QueryRef>)
}
}
}

View file

@ -106,6 +106,7 @@ impl ToOwned for SampleRef {
type Owned = GstRc<SampleRef>;
fn to_owned(&self) -> GstRc<SampleRef> {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) }
}
}

View file

@ -50,7 +50,7 @@ impl Segment {
if T::get_default_format() == Format::Undefined
|| T::get_default_format() == self.get_format()
{
Some(unsafe { mem::transmute(self) })
Some(unsafe { &*(self as *const FormattedSegment<GenericFormattedValue> as *const FormattedSegment<T>) })
} else {
None
}
@ -60,7 +60,7 @@ impl Segment {
if T::get_default_format() == Format::Undefined
|| T::get_default_format() == self.get_format()
{
Some(unsafe { mem::transmute(self) })
Some(unsafe { &mut *(self as *mut FormattedSegment<GenericFormattedValue> as *mut FormattedSegment<T>) })
} else {
None
}
@ -83,7 +83,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
}
pub fn upcast_ref(&self) -> &Segment {
unsafe { mem::transmute(self) }
unsafe { &*(self as *const FormattedSegment<T> as *const FormattedSegment<GenericFormattedValue>) }
}
pub fn reset(&mut self) {
@ -353,6 +353,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
self.0.rate
}
#[cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
pub fn set_rate(&mut self, rate: f64) {
assert_ne!(rate, 0.0);
self.0.rate = rate;
@ -362,6 +363,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
self.0.applied_rate
}
#[cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
pub fn set_applied_rate(&mut self, applied_rate: f64) {
assert_ne!(applied_rate, 0.0);
self.0.applied_rate = applied_rate;
@ -489,7 +491,7 @@ impl<T: FormattedValue> Clone for FormattedSegment<T> {
impl<T: FormattedValue> AsRef<Segment> for FormattedSegment<T> {
fn as_ref(&self) -> &Segment {
unsafe { mem::transmute(self) }
unsafe { &*(self as *const FormattedSegment<T> as *const FormattedSegment<GenericFormattedValue>) }
}
}

View file

@ -21,7 +21,7 @@ impl<'a> Iter<'a> {
fn new(collection: &'a StreamCollection) -> Iter<'a> {
skip_assert_initialized!();
Iter {
collection: collection,
collection,
idx: 0,
size: collection.len() as u32,
}

View file

@ -538,9 +538,9 @@ impl<'a> FieldIterator<'a> {
let n_fields = structure.n_fields();
FieldIterator {
structure: structure,
structure,
idx: 0,
n_fields: n_fields,
n_fields,
}
}
}

View file

@ -238,7 +238,7 @@ impl TagListRef {
unsafe { ffi::gst_tag_list_n_tags(self.as_ptr()) }
}
pub fn nth_tag_name<'a>(&'a self, idx: u32) -> &'a str {
pub fn nth_tag_name(&self, idx: u32) -> &str {
unsafe { CStr::from_ptr(ffi::gst_tag_list_nth_tag_name(self.as_ptr(), idx)).to_str().unwrap() }
}
@ -279,7 +279,7 @@ impl TagListRef {
GenericTagIterator::new(self, tag_name)
}
pub fn iter_tag_list<'a>(&'a self) -> TagListIterator<'a> {
pub fn iter_tag_list(&self) -> TagListIterator {
TagListIterator::new(self)
}
@ -350,7 +350,7 @@ impl<'a, T: Tag<'a>> TagIterator<'a, T> {
fn new(taglist: &'a TagListRef) -> TagIterator<'a, T> {
skip_assert_initialized!();
TagIterator {
taglist: taglist,
taglist,
idx: 0,
size: taglist.get_size::<T>(),
phantom: PhantomData,
@ -420,7 +420,7 @@ impl<'a> GenericTagIterator<'a> {
fn new(taglist: &'a TagListRef, name: &'a str) -> GenericTagIterator<'a> {
skip_assert_initialized!();
GenericTagIterator {
taglist: taglist,
taglist,
name,
idx: 0,
size: taglist.get_size_by_name(name),
@ -478,7 +478,7 @@ impl<'a> TagListIterator<'a> {
skip_assert_initialized!();
let size = taglist.n_tags();
TagListIterator {
taglist: taglist,
taglist,
idx: 0,
size: if size > 0 {
size as u32

View file

@ -89,6 +89,7 @@ impl ToOwned for TocRef {
type Owned = GstRc<TocRef>;
fn to_owned(&self) -> GstRc<TocRef> {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) }
}
}
@ -234,6 +235,7 @@ impl ToOwned for TocEntryRef {
type Owned = GstRc<TocEntryRef>;
fn to_owned(&self) -> GstRc<TocEntryRef> {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) }
}
}

View file

@ -116,6 +116,7 @@ unsafe extern "C" fn type_find_trampoline(
find: *mut ffi::GstTypeFind,
user_data: glib_ffi::gpointer,
) {
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let func: &&(Fn(&mut TypeFind) + Send + Sync + 'static) = mem::transmute(user_data);
func(&mut *(find as *mut TypeFind));
}
@ -159,7 +160,7 @@ impl<T: AsRef<[u8]>> SliceTypeFind<T> {
SliceTypeFind {
probability: None,
caps: None,
data: data,
data,
}
}
@ -180,7 +181,7 @@ impl<T: AsRef<[u8]>> SliceTypeFind<T> {
let mut t = SliceTypeFind {
probability: None,
caps: None,
data: data,
data,
};
t.run();

View file

@ -12,6 +12,7 @@ use glib_ffi;
pub struct MutexGuard<'a>(&'a glib_ffi::GMutex);
impl<'a> MutexGuard<'a> {
#[cfg_attr(feature = "cargo-clippy", allow(trivially_copy_pass_by_ref))]
pub fn lock(mutex: &'a glib_ffi::GMutex) -> Self {
unsafe {
glib_ffi::g_mutex_lock(mut_override(mutex));

View file

@ -249,9 +249,9 @@ impl IntRange<i32> {
assert!(step > 0);
Self {
min: min,
max: max,
step: step,
min,
max,
step,
}
}
}
@ -269,9 +269,9 @@ impl IntRange<i64> {
assert!(step > 0);
Self {
min: min,
max: max,
step: step,
min,
max,
step,
}
}
}
@ -375,7 +375,7 @@ impl FractionRange {
assert!(min <= max);
FractionRange { min: min, max: max }
FractionRange { min, max }
}
pub fn min(&self) -> Fraction {
@ -564,6 +564,7 @@ impl<'a> FromValue<'a> for Array<'a> {
if arr.is_null() {
Array(Cow::Borrowed(&[]))
} else {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
Array(Cow::Borrowed(slice::from_raw_parts(
(*arr).data as *const glib::SendValue,
(*arr).len as usize,
@ -635,6 +636,7 @@ impl<'a> FromValue<'a> for List<'a> {
if arr.is_null() {
List(Cow::Borrowed(&[]))
} else {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
List(Cow::Borrowed(slice::from_raw_parts(
(*arr).data as *const glib::SendValue,
(*arr).len as usize,

View file

@ -38,7 +38,7 @@ fn tutorial_main() {
// Listen to the bus
let bus = playbin.get_bus().unwrap();
let mut custom_data = CustomData {
playbin: playbin,
playbin,
playing: false,
terminate: false,
seek_enabled: false,

View file

@ -157,10 +157,10 @@ fn main() {
let mut buffer = gst::Buffer::with_size(CHUNK_SIZE).unwrap();
let num_samples = CHUNK_SIZE / 2; /* Each sample is 16 bits */
let pts = gst::SECOND
.mul_div_floor(data.num_samples, SAMPLE_RATE as u64)
.mul_div_floor(data.num_samples, u64::from(SAMPLE_RATE))
.expect("u64 overflow");
let duration = gst::SECOND
.mul_div_floor(num_samples as u64, SAMPLE_RATE as u64)
.mul_div_floor(num_samples as u64, u64::from(SAMPLE_RATE))
.expect("u64 overflow");
{