Implement From instead of Into for FlowError -> FlowReturn

It is recommended to implement From as that is more flexible and
includes an implicit Into instance.
This commit is contained in:
Arun Raghavan 2018-10-27 20:19:42 +01:00 committed by Sebastian Dröge
parent c5c3726668
commit 20910b2415

View file

@ -50,15 +50,15 @@ pub enum FlowError {
Error(gst::ErrorMessage), Error(gst::ErrorMessage),
} }
impl Into<gst::FlowReturn> for FlowError { impl From<FlowError> for gst::FlowReturn {
fn into(self) -> gst::FlowReturn { fn from(err: FlowError) -> Self {
(&self).into() gst::FlowReturn::from(&err)
} }
} }
impl<'a> Into<gst::FlowReturn> for &'a FlowError { impl<'a> From<&'a FlowError> for gst::FlowReturn {
fn into(self) -> gst::FlowReturn { fn from(err: &FlowError) -> gst::FlowReturn {
match *self { match *err {
FlowError::Flushing => gst::FlowReturn::Flushing, FlowError::Flushing => gst::FlowReturn::Flushing,
FlowError::Eos => gst::FlowReturn::Eos, FlowError::Eos => gst::FlowReturn::Eos,
FlowError::NotNegotiated(..) => gst::FlowReturn::NotNegotiated, FlowError::NotNegotiated(..) => gst::FlowReturn::NotNegotiated,