Make bssl-crypto no_std compatible
Bug: 649
Change-Id: Ib47e843496e58a5cdb3cd04b3929e0a08ba09744
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/63145
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/rust/bssl-crypto/src/lib.rs b/rust/bssl-crypto/src/lib.rs
index cd40b81..e53469d 100644
--- a/rust/bssl-crypto/src/lib.rs
+++ b/rust/bssl-crypto/src/lib.rs
@@ -21,8 +21,10 @@
clippy::panic,
clippy::expect_used
)]
+#![cfg_attr(not(any(feature = "std", test)), no_std)]
//! Rust BoringSSL bindings
+extern crate alloc;
extern crate core;
@@ -79,7 +81,7 @@
/// Returns a raw pointer to the value, which is safe to pass over FFI.
pub fn as_ptr<T>(&self) -> *const T {
if self.0.is_empty() {
- std::ptr::null()
+ core::ptr::null()
} else {
self.0.as_ptr() as *const T
}
@@ -97,7 +99,7 @@
/// Returns a raw pointer to the value, which is safe to pass over FFI.
pub fn as_mut_ptr<T>(&mut self) -> *mut T {
if self.0.is_empty() {
- std::ptr::null_mut()
+ core::ptr::null_mut()
} else {
self.0.as_mut_ptr() as *mut T
}