diff --git a/gstreamer-sdp/src/sdp_media.rs b/gstreamer-sdp/src/sdp_media.rs index cdbd8417f..fd8f8bd08 100644 --- a/gstreamer-sdp/src/sdp_media.rs +++ b/gstreamer-sdp/src/sdp_media.rs @@ -228,11 +228,7 @@ impl SDPMediaRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -243,11 +239,7 @@ impl SDPMediaRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -296,11 +288,7 @@ impl SDPMediaRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -311,11 +299,7 @@ impl SDPMediaRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -337,11 +321,7 @@ impl SDPMediaRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -360,11 +340,7 @@ impl SDPMediaRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } diff --git a/gstreamer-sdp/src/sdp_message.rs b/gstreamer-sdp/src/sdp_message.rs index e2cee49a4..df00a30cc 100644 --- a/gstreamer-sdp/src/sdp_message.rs +++ b/gstreamer-sdp/src/sdp_message.rs @@ -266,11 +266,7 @@ impl SDPMessageRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -281,11 +277,7 @@ impl SDPMessageRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -326,11 +318,7 @@ impl SDPMessageRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -341,11 +329,7 @@ impl SDPMessageRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -412,11 +396,7 @@ impl SDPMessageRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -427,11 +407,7 @@ impl SDPMessageRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -457,11 +433,7 @@ impl SDPMessageRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } } @@ -472,11 +444,7 @@ impl SDPMessageRef { if ptr.is_null() { None } else { - let result = CStr::from_ptr(ptr).to_str(); - match result { - Ok(attr) => Some(attr), - Err(_) => None, - } + CStr::from_ptr(ptr).to_str().ok() } } }