Add support for no_std

pull/58/head
Alexey Arbuzov 6 years ago
parent 40d24f38aa
commit 8eb6e776fe

@ -9,3 +9,8 @@ readme = "Readme.markdown"
keywords = ["qr-code", "barcode", "encoder", "image"]
categories = ["encoding", "multimedia::images"]
license = "MIT"
[features]
default = ["std"]
std = []
alloc = [] # required for nightly compiler before 1.36.0

@ -79,7 +79,22 @@
//! }
//! }
//! ```
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "alloc", feature(alloc))]
#![cfg(not(feature = "std"))]
#[macro_use] extern crate alloc;
#[cfg(not(feature = "std"))]
use alloc::{string::String, vec::Vec};
#[cfg(not(feature = "std"))]
mod std {
pub use core::i32;
pub use core::cmp;
pub use core::fmt;
pub use alloc::collections;
}
/*---- QrCode functionality ----*/
@ -1274,6 +1289,7 @@ impl BitBuffer {
#[derive(Debug, Clone)]
pub struct DataTooLong(String);
#[cfg(feature = "std")]
impl std::error::Error for DataTooLong {
fn description(&self) -> &str {
&self.0

Loading…
Cancel
Save