diff --git a/src/key/dynamic.rs b/src/key/dynamic.rs index d359d528..273d527e 100644 --- a/src/key/dynamic.rs +++ b/src/key/dynamic.rs @@ -1,37 +1,12 @@ -#[cfg(not(feature = "std"))] use alloc::borrow::Cow; -#[cfg(not(feature = "std"))] use alloc::string::{String, ToString}; -#[cfg(not(feature = "std"))] use core::clone::Clone; -#[cfg(not(feature = "std"))] use core::cmp::PartialEq; -#[cfg(not(feature = "std"))] use core::convert::{AsRef, From}; -#[cfg(not(feature = "std"))] use core::fmt; -#[cfg(not(feature = "std"))] use core::hash::{Hash, Hasher}; -#[cfg(not(feature = "std"))] use core::iter::{FromIterator, IntoIterator}; -#[cfg(feature = "std")] -use std::borrow::Cow; -#[cfg(feature = "std")] -use std::cmp::PartialEq; -#[cfg(feature = "std")] -use std::convert::{AsRef, From}; -#[cfg(feature = "std")] -use std::fmt; -#[cfg(feature = "std")] -use std::hash::{Hash, Hasher}; -#[cfg(feature = "std")] -use std::iter::{FromIterator, IntoIterator}; -#[cfg(feature = "std")] -use std::string::String; -#[cfg(feature = "std")] -use std::string::ToString; - /// Opaque Key is a representation of a key. /// /// It is owned, and largely forms a contract for diff --git a/src/lib.rs b/src/lib.rs index 454a2ce8..f01cc667 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -279,41 +279,27 @@ // {{{ Imports & meta #![warn(missing_docs)] #![warn(rust_2018_idioms)] -#![no_std] +#![warn( + // Use `core` and `alloc` instead of `std` wherever possible + clippy::alloc_instead_of_core, + clippy::std_instead_of_core, + clippy::std_instead_of_alloc, +)] +#![cfg_attr(not(feature = "std"), no_std)] -#[cfg(not(feature = "std"))] extern crate alloc; -#[macro_use] -#[cfg(feature = "std")] -extern crate std; mod key; pub use self::key::Key; -#[cfg(not(feature = "std"))] + use alloc::borrow::{Cow, ToOwned}; -#[cfg(not(feature = "std"))] use alloc::boxed::Box; -#[cfg(not(feature = "std"))] use alloc::rc::Rc; -#[cfg(not(feature = "std"))] use alloc::string::String; -#[cfg(not(feature = "std"))] use alloc::{sync::Arc, vec::Vec}; use core::str::FromStr; use core::{convert, fmt, result}; -#[cfg(feature = "std")] -use std::borrow::{Cow, ToOwned}; -#[cfg(feature = "std")] -use std::boxed::Box; -#[cfg(feature = "std")] -use std::rc::Rc; -#[cfg(feature = "std")] -use std::string::String; -#[cfg(feature = "std")] -use std::sync::Arc; -#[cfg(feature = "std")] -use std::vec::Vec; // }}} // {{{ Macros @@ -3926,7 +3912,7 @@ pub enum Error { /// `io::Error` (not available in ![no_std] mode) Io(std::io::Error), /// `fmt::Error` - Fmt(std::fmt::Error), + Fmt(core::fmt::Error), /// Other error Other, } @@ -3996,7 +3982,7 @@ impl std::error::Error for Error { #[cfg(feature = "std")] impl core::fmt::Display for Error { - fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match *self { Error::Io(ref e) => e.fmt(fmt), Error::Fmt(ref e) => e.fmt(fmt),