From 57799a188bf5afef180dd70981f9882c7b695ea7 Mon Sep 17 00:00:00 2001 From: Ryan Kennedy Date: Sun, 29 Mar 2020 17:27:46 -0500 Subject: [PATCH] Feature alloc for graphics --- Cargo.toml | 7 +++++++ src/lib.rs | 1 + src/writers/mod.rs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 5d2e8ba..aca89c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,3 +28,10 @@ x86_64 = "0.9.6" [dependencies.num-traits] version = "0.2.11" default-features = false + +[features] +default = [] +alloc = [] + +[package.metadata.docs.rs] +features = ["alloc"] diff --git a/src/lib.rs b/src/lib.rs index 5c486e8..c90ef6a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,7 @@ #![no_std] #![warn(missing_docs)] +#[cfg(feature = "alloc")] extern crate alloc; pub mod colors; diff --git a/src/writers/mod.rs b/src/writers/mod.rs index 92c55f4..7ecc65d 100644 --- a/src/writers/mod.rs +++ b/src/writers/mod.rs @@ -1,5 +1,7 @@ //! Writers for common vga modes. +#[cfg(feature = "alloc")] mod graphics_320x200x256; +#[cfg(feature = "alloc")] mod graphics_640x480x16; mod text_40x25; mod text_40x50; @@ -11,7 +13,9 @@ use super::{ vga::VGA, }; +#[cfg(feature = "alloc")] pub use graphics_320x200x256::Graphics320x200x256; +#[cfg(feature = "alloc")] pub use graphics_640x480x16::Graphics640x480x16; pub use text_40x25::Text40x25; pub use text_40x50::Text40x50;