From 51540739c55f2124e8fee0b68621bc6e28271ff9 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 4 Sep 2024 12:51:43 +0200 Subject: [PATCH] Prepare for making the crate `no_std` --- Cargo.toml | 5 +++++ src/lib.rs | 7 +++++++ 2 files changed, 12 insertions(+) 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 dd41f65..66c059b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -124,6 +124,7 @@ //! do not modify common `CALayer` properties of the layer that `raw-window-metal` creates, since //! they may just end up being overwritten (see also "Semantics" above). +#![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)] @@ -142,6 +143,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)]