proptest/
std_facade.rs

1//-
2// Copyright 2017, 2018 The proptest developers
3//
4// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7// option. This file may not be copied, modified, or distributed
8// except according to those terms.
9
10//! This module provides #[cfg(..)]ed type aliases over features.
11
12macro_rules! multiplex_alloc {
13    ($($alloc: path, $std: path),*) => {
14        $(
15            #[cfg(all(feature = "alloc", not(feature = "std")))]
16            pub use $alloc;
17            #[cfg(feature = "std")]
18            pub use $std;
19        )*
20    };
21}
22
23macro_rules! multiplex_core {
24    ($($core: path, $std: path),*) => {
25        $(
26            #[cfg(not(feature = "std"))]
27            pub use $core;
28            #[cfg(feature = "std")]
29            pub use $std;
30        )*
31    };
32}
33
34multiplex_alloc! {
35    alloc::borrow::Cow, ::std::borrow::Cow,
36    alloc::borrow::ToOwned, ::std::borrow::ToOwned,
37    alloc::boxed::Box, ::std::boxed::Box,
38    alloc::string::String, ::std::string::String,
39    alloc::string, ::std::string,
40    alloc::sync::Arc, ::std::sync::Arc,
41    alloc::rc::Rc, ::std::rc::Rc,
42    alloc::vec::Vec, ::std::vec::Vec,
43    alloc::vec, ::std::vec,
44    alloc::collections::VecDeque, std::collections::VecDeque,
45    alloc::collections::vec_deque, std::collections::vec_deque,
46    alloc::collections::BinaryHeap, ::std::collections::BinaryHeap,
47    alloc::collections::binary_heap, ::std::collections::binary_heap,
48    alloc::collections::LinkedList, ::std::collections::LinkedList,
49    alloc::collections::linked_list, ::std::collections::linked_list,
50    alloc::collections::BTreeSet, ::std::collections::BTreeSet,
51    alloc::collections::BTreeMap, ::std::collections::BTreeMap,
52    alloc::collections::btree_map, ::std::collections::btree_map,
53    alloc::collections::btree_set, ::std::collections::btree_set
54}
55
56#[cfg(feature = "std")]
57multiplex_alloc! {
58    hashmap_core::HashMap, ::std::collections::HashMap,
59    hashmap_core::HashSet, ::std::collections::HashSet
60}
61
62//#[cfg(not(feature = "std"))]
63//pub(crate) use hashmap_core::map as hash_map;
64#[cfg(feature = "std")]
65pub use ::std::collections::hash_map;
66//#[cfg(not(feature = "std"))]
67//pub(crate) use hashmap_core::set as hash_set;
68#[cfg(feature = "std")]
69pub use ::std::collections::hash_set;
70
71multiplex_core! {
72    core::fmt, ::std::fmt,
73    core::cell::Cell, ::std::cell::Cell
74}