diff --git a/src/lib.rs b/src/lib.rs index b976017..ab1d556 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,20 +2,23 @@ //! //! See the [`LinearMap`](struct.LinearMap.html) type for details. +#![no_std] #![deny(missing_docs)] +extern crate alloc; + // Optional Serde support #[cfg(feature = "serde_impl")] pub mod serde; pub mod set; -use std::borrow::Borrow; -use std::fmt::{self, Debug}; -use std::iter; -use std::mem; -use std::ops; -use std::slice; -use std::vec; +use alloc::vec::{self, Vec}; +use core::borrow::Borrow; +use core::fmt::{self, Debug}; +use core::iter; +use core::mem; +use core::ops; +use core::slice; use self::Entry::{Occupied, Vacant}; @@ -79,7 +82,9 @@ pub struct LinearMap { impl LinearMap { /// Creates an empty map. This method does not allocate. pub fn new() -> Self { - LinearMap { storage: vec![] } + LinearMap { + storage: Vec::new(), + } } /// Creates an empty map with the given initial capacity. diff --git a/src/serde.rs b/src/serde.rs index 0976085..298f95a 100644 --- a/src/serde.rs +++ b/src/serde.rs @@ -16,8 +16,8 @@ use self::serde::de::{Error, MapAccess, SeqAccess, Visitor}; use self::serde::ser::{SerializeMap, SerializeSeq}; use self::serde::{Deserialize, Deserializer, Serialize, Serializer}; -use std::fmt; -use std::marker::PhantomData; +use core::fmt; +use core::marker::PhantomData; impl Serialize for LinearMap where diff --git a/src/set.rs b/src/set.rs index a3246df..cd23f95 100644 --- a/src/set.rs +++ b/src/set.rs @@ -2,10 +2,11 @@ //! //! See the [`LinearSet`](struct.LinearSet.html) type for details. -use std::borrow::Borrow; -use std::fmt; -use std::iter::{Chain, FromIterator}; -use std::ops::{BitAnd, BitOr, BitXor, Sub}; +use alloc::vec::Vec; +use core::borrow::Borrow; +use core::fmt; +use core::iter::{Chain, FromIterator}; +use core::ops::{BitAnd, BitOr, BitXor, Sub}; use super::{Keys, LinearMap}; @@ -574,13 +575,13 @@ where impl From> for Vec { fn from(other: LinearSet) -> Self { - unsafe { std::mem::transmute(other) } + unsafe { core::mem::transmute(other) } } } impl From> for LinearSet { fn from(other: Vec) -> Self { - unsafe { std::mem::transmute(other) } + unsafe { core::mem::transmute(other) } } }