Import from libcore where possible
diff --git a/src/cxx_string.rs b/src/cxx_string.rs
index 95d560e..5780e3e 100644
--- a/src/cxx_string.rs
+++ b/src/cxx_string.rs
@@ -1,7 +1,7 @@
-use std::borrow::Cow;
-use std::fmt::{self, Debug, Display};
-use std::slice;
-use std::str::{self, Utf8Error};
+use alloc::borrow::Cow;
+use core::fmt::{self, Debug, Display};
+use core::slice;
+use core::str::{self, Utf8Error};
extern "C" {
#[link_name = "cxxbridge04$cxx_string$data"]
diff --git a/src/cxx_vector.rs b/src/cxx_vector.rs
index a7d3f2f..78b8f20 100644
--- a/src/cxx_vector.rs
+++ b/src/cxx_vector.rs
@@ -1,9 +1,9 @@
use crate::cxx_string::CxxString;
-use std::ffi::c_void;
-use std::fmt::{self, Display};
-use std::marker::PhantomData;
-use std::mem;
-use std::ptr;
+use core::ffi::c_void;
+use core::fmt::{self, Display};
+use core::marker::PhantomData;
+use core::mem;
+use core::ptr;
/// Binding to C++ `std::vector<T, std::allocator<T>>`.
///
diff --git a/src/exception.rs b/src/exception.rs
index 125e484..e85bf61 100644
--- a/src/exception.rs
+++ b/src/exception.rs
@@ -1,4 +1,4 @@
-use std::fmt::{self, Debug, Display};
+use core::fmt::{self, Debug, Display};
/// Exception thrown from an `extern "C"` function.
#[derive(Debug)]
diff --git a/src/lib.rs b/src/lib.rs
index 8c828a3..fd623e8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -370,6 +370,8 @@
#[cfg(built_with_cargo)]
extern crate link_cplusplus;
+extern crate alloc;
+
#[macro_use]
mod macros;
diff --git a/src/opaque.rs b/src/opaque.rs
index 0ff6bb9..bad57e7 100644
--- a/src/opaque.rs
+++ b/src/opaque.rs
@@ -1,4 +1,4 @@
-use std::mem;
+use core::mem;
// . size = 0
// . align = 1
diff --git a/src/result.rs b/src/result.rs
index 72c4959..8b4bb75 100644
--- a/src/result.rs
+++ b/src/result.rs
@@ -1,10 +1,10 @@
use crate::exception::Exception;
use crate::rust_str::RustStr;
-use std::fmt::Display;
-use std::ptr;
-use std::result::Result as StdResult;
-use std::slice;
-use std::str;
+use core::fmt::Display;
+use core::ptr;
+use core::result::Result as StdResult;
+use core::slice;
+use core::str;
#[repr(C)]
pub union Result {
diff --git a/src/rust_sliceu8.rs b/src/rust_sliceu8.rs
index f509c7f..32f8798 100644
--- a/src/rust_sliceu8.rs
+++ b/src/rust_sliceu8.rs
@@ -1,6 +1,6 @@
-use std::mem;
-use std::ptr::NonNull;
-use std::slice;
+use core::mem;
+use core::ptr::NonNull;
+use core::slice;
// Not necessarily ABI compatible with &[u8]. Codegen performs the translation.
#[repr(C)]
diff --git a/src/rust_str.rs b/src/rust_str.rs
index b944ede..38e5cab 100644
--- a/src/rust_str.rs
+++ b/src/rust_str.rs
@@ -1,7 +1,7 @@
-use std::mem;
-use std::ptr::NonNull;
-use std::slice;
-use std::str;
+use core::mem;
+use core::ptr::NonNull;
+use core::slice;
+use core::str;
// Not necessarily ABI compatible with &str. Codegen performs the translation.
#[repr(C)]
diff --git a/src/rust_string.rs b/src/rust_string.rs
index f0d1df1..d10714b 100644
--- a/src/rust_string.rs
+++ b/src/rust_string.rs
@@ -1,4 +1,4 @@
-use std::mem;
+use core::mem;
#[repr(C)]
pub struct RustString {
diff --git a/src/rust_vec.rs b/src/rust_vec.rs
index 6f1d567..3ae5d5e 100644
--- a/src/rust_vec.rs
+++ b/src/rust_vec.rs
@@ -1,5 +1,5 @@
use crate::rust_string::RustString;
-use std::mem::ManuallyDrop;
+use core::mem::ManuallyDrop;
#[repr(C)]
pub struct RustVec<T> {
diff --git a/src/symbols/exception.rs b/src/symbols/exception.rs
index 7484d1c..7449f14 100644
--- a/src/symbols/exception.rs
+++ b/src/symbols/exception.rs
@@ -1,4 +1,4 @@
-use std::slice;
+use core::slice;
#[export_name = "cxxbridge04$exception"]
unsafe extern "C" fn exception(ptr: *const u8, len: usize) -> *const u8 {
diff --git a/src/symbols/rust_str.rs b/src/symbols/rust_str.rs
index 5111c6a..823173a 100644
--- a/src/symbols/rust_str.rs
+++ b/src/symbols/rust_str.rs
@@ -1,5 +1,5 @@
-use std::slice;
-use std::str;
+use core::slice;
+use core::str;
#[export_name = "cxxbridge04$str$valid"]
unsafe extern "C" fn str_valid(ptr: *const u8, len: usize) -> bool {
diff --git a/src/symbols/rust_string.rs b/src/symbols/rust_string.rs
index 5c2982d..67c53e1 100644
--- a/src/symbols/rust_string.rs
+++ b/src/symbols/rust_string.rs
@@ -1,7 +1,7 @@
-use std::mem::{ManuallyDrop, MaybeUninit};
-use std::ptr;
-use std::slice;
-use std::str;
+use core::mem::{ManuallyDrop, MaybeUninit};
+use core::ptr;
+use core::slice;
+use core::str;
#[export_name = "cxxbridge04$string$new"]
unsafe extern "C" fn string_new(this: &mut MaybeUninit<String>) {
diff --git a/src/symbols/rust_vec.rs b/src/symbols/rust_vec.rs
index fb49b40..667296f 100644
--- a/src/symbols/rust_vec.rs
+++ b/src/symbols/rust_vec.rs
@@ -1,7 +1,7 @@
use crate::rust_string::RustString;
use crate::rust_vec::RustVec;
-use std::mem;
-use std::ptr;
+use core::mem;
+use core::ptr;
macro_rules! rust_vec_shims {
($segment:expr, $ty:ty) => {
diff --git a/src/unique_ptr.rs b/src/unique_ptr.rs
index 0428b5f..2a731d7 100644
--- a/src/unique_ptr.rs
+++ b/src/unique_ptr.rs
@@ -1,11 +1,11 @@
use crate::cxx_string::CxxString;
use crate::cxx_vector::{self, CxxVector, VectorElement};
-use std::ffi::c_void;
-use std::fmt::{self, Debug, Display};
-use std::marker::PhantomData;
-use std::mem;
-use std::ops::{Deref, DerefMut};
-use std::ptr;
+use core::ffi::c_void;
+use core::fmt::{self, Debug, Display};
+use core::marker::PhantomData;
+use core::mem;
+use core::ops::{Deref, DerefMut};
+use core::ptr;
/// Binding to C++ `std::unique_ptr<T, std::default_delete<T>>`.
#[repr(C)]