summaryrefslogtreecommitdiff
path: root/rust/src/string.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/string.rs')
-rw-r--r--rust/src/string.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/rust/src/string.rs b/rust/src/string.rs
index e042dbdd..198c764b 100644
--- a/rust/src/string.rs
+++ b/rust/src/string.rs
@@ -21,6 +21,14 @@ use std::os::raw;
use crate::rc::*;
+pub(crate) fn raw_to_string(ptr: *const raw::c_char) -> Option<String> {
+ if ptr.is_null() {
+ None
+ } else {
+ Some(unsafe { CStr::from_ptr(ptr).to_string_lossy().into_owned() })
+ }
+}
+
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
#[repr(C)]
pub struct BnStr {