util::color:*: use pointer .as_ref()

This commit is contained in:
Zhiming Wang 2018-09-14 21:49:26 -04:00
parent 2d3a34f74d
commit c5525851d4
No known key found for this signature in database
GPG Key ID: 5B58F95EC95965D8
4 changed files with 4 additions and 20 deletions

View File

@ -31,11 +31,7 @@ impl Primaries {
}
unsafe {
let ptr = av_color_primaries_name((*self).into());
if ptr.is_null() {
None
} else {
Some(from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
}
ptr.as_ref().map(|ptr| from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
}
}
}

View File

@ -18,11 +18,7 @@ impl Range {
}
unsafe {
let ptr = av_color_range_name((*self).into());
if ptr.is_null() {
None
} else {
Some(from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
}
ptr.as_ref().map(|ptr| from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
}
}
}

View File

@ -32,11 +32,7 @@ impl Space {
}
unsafe {
let ptr = av_color_space_name((*self).into());
if ptr.is_null() {
None
} else {
Some(from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
}
ptr.as_ref().map(|ptr| from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
}
}
}

View File

@ -34,11 +34,7 @@ impl TransferCharacteristic {
}
unsafe {
let ptr = av_color_transfer_name((*self).into());
if ptr.is_null() {
None
} else {
Some(from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
}
ptr.as_ref().map(|ptr| from_utf8_unchecked(CStr::from_ptr(ptr).to_bytes()))
}
}
}