diff --git a/Cargo.toml b/Cargo.toml index 124b520..334263d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,11 @@ keywords = ["window", "metal", "graphics"] categories = ["game-engines", "graphics"] exclude = [".github/*"] +[features] +default = ["std"] +std = ["alloc"] +alloc = [] + [target.'cfg(target_vendor = "apple")'.dependencies] objc2 = "0.5.2" objc2-foundation = { version = "0.2.2", features = [ diff --git a/src/lib.rs b/src/lib.rs index 2350ff7..2a96a55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -97,6 +97,7 @@ //! //! Option 3 seems like the most robust solution, so this is what this crate does. +#![no_std] #![cfg(target_vendor = "apple")] #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide), doc(cfg_hide(doc)))] #![deny(unsafe_op_in_unsafe_fn)] @@ -113,6 +114,12 @@ use objc2::{msg_send_id, ClassType}; use objc2_foundation::{MainThreadMarker, NSObject, NSObjectProtocol}; use objc2_quartz_core::{CALayer, CAMetalLayer}; +#[cfg(not(feature = "alloc"))] +compile_error!("The `alloc` feature must currently be enabled."); + +#[cfg(not(feature = "std"))] +compile_error!("The `std` feature must currently be enabled."); + /// A wrapper around [`CAMetalLayer`]. #[doc(alias = "CAMetalLayer")] #[derive(Debug, Clone)]