Skip to content

Commit

Permalink
Prepare for making the crate no_std
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Sep 4, 2024
1 parent 56a1aa3 commit ce52ad2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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)]
Expand Down

0 comments on commit ce52ad2

Please sign in to comment.