summaryrefslogtreecommitdiff
path: root/rust/src/string.rs
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2021-05-19 20:40:24 -0400
committerKyleMiles <krm504@nyu.edu>2021-07-07 23:27:29 -0400
commitd19f5e85ee26c3d6604798d30ab821d15731cada (patch)
tree9851b7f6bf5589df69508d4489c11148515cb550 /rust/src/string.rs
parent0f58b0742e3010eee6bbd2e15f4dd4930ec0d822 (diff)
DebugInfo - plugable debug information importers - C++, Rust, and Python APIs
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 {