aboutsummaryrefslogtreecommitdiff
path: root/libgrust/libformat_parser/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'libgrust/libformat_parser/src/lib.rs')
-rw-r--r--libgrust/libformat_parser/src/lib.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/libgrust/libformat_parser/src/lib.rs b/libgrust/libformat_parser/src/lib.rs
index d920cfa..72e5971 100644
--- a/libgrust/libformat_parser/src/lib.rs
+++ b/libgrust/libformat_parser/src/lib.rs
@@ -21,6 +21,17 @@ where
}
}
+// Extension trait to provide `String::leak` which did not exist in Rust 1.49
+pub trait StringLeakExt {
+ fn leak<'a>(self) -> &'a mut str;
+}
+
+impl StringLeakExt for String {
+ fn leak<'a>(self) -> &'a mut str {
+ Box::leak(self.into_boxed_str())
+ }
+}
+
// FIXME: Make an ffi module in a separate file
// FIXME: Remember to leak the boxed type somehow
// FIXME: How to encode the Option type? As a pointer? Option<T> -> Option<&T> -> *const T could work maybe?