From 9f3ba4e37bfa83f4d459f1d128d53dcc32bb9e3f Mon Sep 17 00:00:00 2001 From: Tomoaki Kawada Date: Sat, 11 Jul 2020 06:56:46 +0900 Subject: [PATCH] make the crate no-std (#4) --- Cargo.toml | 2 +- src/lib.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index feb361b..4624817 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "try-lock" version = "0.2.2" # remember to update html_root_url description = "A lightweight atomic lock." keywords = ["lock", "atomic"] -categories = ["concurrency"] +categories = ["concurrency", "no-std"] authors = ["Sean McArthur "] license = "MIT" repository = "https://github.com/seanmonstar/try-lock" diff --git a/src/lib.rs b/src/lib.rs index 7c0feec..64d3ab8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ #![deny(missing_docs)] #![deny(missing_debug_implementations)] #![deny(warnings)] +#![cfg_attr(not(test), no_std)] //! A light-weight lock guarded by an atomic boolean. //! @@ -43,10 +44,13 @@ //! assert_eq!(locked2.name, "Spanner Bundle"); //! ``` -use std::cell::UnsafeCell; -use std::fmt; -use std::ops::{Deref, DerefMut}; -use std::sync::atomic::{AtomicBool, Ordering}; +#[cfg(test)] +extern crate core; + +use core::cell::UnsafeCell; +use core::fmt; +use core::ops::{Deref, DerefMut}; +use core::sync::atomic::{AtomicBool, Ordering}; /// A light-weight lock guarded by an atomic boolean. ///