pub mod prelude {
pub use super::borrow::ToOwned;
pub use super::boxed::Box;
pub use super::cell::RefCell;
pub use super::clone::Clone;
pub use super::cmp::{Eq, Ord, PartialEq, PartialOrd};
pub use super::convert::{AsMut, AsRef, From, Into};
pub use super::default::Default;
pub use super::iter::{DoubleEndedIterator, ExactSizeIterator, Extend, IntoIterator, Iterator};
pub use super::marker::{Copy, Send, Sized, Sync, Unpin};
pub use super::mem::drop;
pub use super::ops::{Drop, Fn, FnMut, FnOnce};
pub use super::option::Option::{self, None, Some};
pub use super::result::Result::{self, Err, Ok};
pub use super::string::{String, ToString};
pub use super::vec::Vec;
pub use super::convert::{TryFrom, TryInto};
pub use super::iter::FromIterator;
pub use super::borrow;
pub use super::borrow::Cow;
pub use super::cell::*;
pub use super::collections::*;
pub use super::fmt;
pub use super::fmt::{Debug, Display};
pub use super::format;
pub use super::marker::PhantomData;
pub use super::mem;
pub use super::rc::Rc;
pub use super::str::FromStr;
pub use super::vec;
}
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "alloc")]
pub use alloc::borrow;
#[cfg(feature = "alloc")]
pub use alloc::boxed;
#[cfg(feature = "alloc")]
pub use alloc::fmt;
#[cfg(feature = "alloc")]
pub use alloc::format;
#[cfg(feature = "alloc")]
pub use alloc::rc;
#[cfg(feature = "alloc")]
pub use alloc::str;
#[cfg(feature = "alloc")]
pub use alloc::string;
#[cfg(feature = "alloc")]
pub use alloc::sync;
#[cfg(feature = "alloc")]
pub use alloc::vec;
#[cfg(feature = "alloc")]
pub use core::cell;
#[cfg(feature = "alloc")]
pub use core::clone;
#[cfg(feature = "alloc")]
pub use core::cmp;
#[cfg(feature = "alloc")]
pub use core::convert;
#[cfg(feature = "alloc")]
pub use core::default;
#[cfg(feature = "alloc")]
pub use core::hash;
#[cfg(feature = "alloc")]
pub use core::iter;
#[cfg(feature = "alloc")]
pub use core::marker;
#[cfg(feature = "alloc")]
pub use core::mem;
#[cfg(feature = "alloc")]
pub use core::num;
#[cfg(feature = "alloc")]
pub use core::ops;
#[cfg(feature = "alloc")]
pub use core::option;
#[cfg(feature = "alloc")]
pub use core::ptr;
#[cfg(feature = "alloc")]
pub use core::result;
#[cfg(feature = "alloc")]
pub use core::slice;
#[cfg(not(feature = "alloc"))]
pub use core::hash;
#[cfg(not(feature = "alloc"))]
pub use std::alloc;
#[cfg(not(feature = "alloc"))]
pub use std::borrow;
#[cfg(not(feature = "alloc"))]
pub use std::boxed;
#[cfg(not(feature = "alloc"))]
pub use std::cell;
#[cfg(not(feature = "alloc"))]
pub use std::clone;
#[cfg(not(feature = "alloc"))]
pub use std::cmp;
#[cfg(not(feature = "alloc"))]
pub use std::convert;
#[cfg(not(feature = "alloc"))]
pub use std::default;
#[cfg(not(feature = "alloc"))]
pub use std::fmt;
#[cfg(not(feature = "alloc"))]
pub use std::format;
#[cfg(not(feature = "alloc"))]
pub use std::iter;
#[cfg(not(feature = "alloc"))]
pub use std::marker;
#[cfg(not(feature = "alloc"))]
pub use std::mem;
#[cfg(not(feature = "alloc"))]
pub use std::num;
#[cfg(not(feature = "alloc"))]
pub use std::ops;
#[cfg(not(feature = "alloc"))]
pub use std::option;
#[cfg(not(feature = "alloc"))]
pub use std::ptr;
#[cfg(not(feature = "alloc"))]
pub use std::rc;
#[cfg(not(feature = "alloc"))]
pub use std::result;
#[cfg(not(feature = "alloc"))]
pub use std::slice;
#[cfg(not(feature = "alloc"))]
pub use std::str;
#[cfg(not(feature = "alloc"))]
pub use std::string;
#[cfg(not(feature = "alloc"))]
pub use std::sync;
#[cfg(not(feature = "alloc"))]
pub use std::vec;
pub mod collections {
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "alloc")]
pub use alloc::collections::LinkedList;
#[cfg(not(feature = "alloc"))]
pub use std::collections::LinkedList;
#[cfg(feature = "alloc")]
pub use alloc::collections::VecDeque;
#[cfg(not(feature = "alloc"))]
pub use std::collections::VecDeque;
pub mod btree_map {
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "alloc")]
pub use alloc::collections::btree_map::*;
#[cfg(not(feature = "alloc"))]
pub use std::collections::btree_map::*;
#[cfg(feature = "alloc")]
pub use alloc::collections::BTreeMap;
#[cfg(not(feature = "alloc"))]
pub use std::collections::BTreeMap;
#[macro_export]
macro_rules! btreemap {
( ) => ({
$crate::rust::collections::btree_map::BTreeMap::new()
});
( $($key:expr => $value:expr),* ) => ({
let mut temp = $crate::rust::collections::btree_map::BTreeMap::new();
$(
temp.insert($key, $value);
)*
temp
});
( $($key:expr => $value:expr,)* ) => (
$crate::rust::collections::btree_map::btreemap!{$($key => $value),*}
);
}
pub use btreemap;
}
pub mod btree_set {
#[cfg(feature = "alloc")]
extern crate alloc;
#[cfg(feature = "alloc")]
pub use alloc::collections::btree_set::*;
#[cfg(not(feature = "alloc"))]
pub use std::collections::btree_set::*;
#[cfg(feature = "alloc")]
pub use alloc::collections::BTreeSet;
#[cfg(not(feature = "alloc"))]
pub use std::collections::BTreeSet;
#[macro_export]
macro_rules! btreeset {
( ) => ({
$crate::rust::collections::btree_set::BTreeSet::new()
});
( $($value:expr),* ) => ({
let mut temp = $crate::rust::collections::btree_set::BTreeSet::new();
$(
temp.insert($value);
)*
temp
});
( $($value:expr,)* ) => (
$crate::rust::collections::btree_set::btreeset!{$($value),*}
);
}
pub use btreeset;
}
#[cfg(feature = "fuzzing")]
pub mod stub_hasher {
use core::hash::{BuildHasher, Hasher};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StubHasher {
seed: u64,
}
impl Hasher for StubHasher {
fn write(&mut self, _bytes: &[u8]) {}
fn finish(&self) -> u64 {
self.seed
}
}
impl BuildHasher for StubHasher {
type Hasher = StubHasher;
fn build_hasher(&self) -> Self::Hasher {
StubHasher { seed: self.seed }
}
}
impl StubHasher {
fn new() -> Self {
StubHasher { seed: 0 }
}
}
impl Default for StubHasher {
fn default() -> Self {
StubHasher::new()
}
}
}
pub mod hash_map {
#[cfg(feature = "fuzzing")]
pub type DefaultHashBuilder = crate::rust::collections::stub_hasher::StubHasher;
#[cfg(all(not(feature = "fuzzing"), feature = "alloc"))]
pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder;
#[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))]
pub type DefaultHashBuilder = std::collections::hash_map::RandomState;
#[cfg(feature = "alloc")]
pub use hashbrown::hash_map::*;
#[cfg(not(feature = "alloc"))]
pub use std::collections::hash_map::*;
#[cfg(feature = "alloc")]
pub use hashbrown::HashMap as ext_HashMap;
#[cfg(not(feature = "alloc"))]
pub use std::collections::HashMap as ext_HashMap;
pub type HashMap<K, V, S = DefaultHashBuilder> = ext_HashMap<K, V, S>;
pub fn new<K, V>() -> HashMap<K, V> {
HashMap::with_capacity_and_hasher(0, DefaultHashBuilder::default())
}
pub fn with_capacity<K, V>(n: usize) -> HashMap<K, V> {
HashMap::with_capacity_and_hasher(n, DefaultHashBuilder::default())
}
#[macro_export]
macro_rules! hashmap {
( ) => ({
$crate::rust::collections::hash_map::HashMap::default()
});
( $($key:expr => $value:expr),* ) => ({
const CAP: usize = <[()]>::len(&[$({ stringify!($key); }),*]);
let mut temp = $crate::rust::collections::hash_map::HashMap::with_capacity(CAP);
$(
temp.insert($key, $value);
)*
temp
});
( $($key:expr => $value:expr,)* ) => (
$crate::rust::collections::hash_map::hashmap!{$($key => $value),*}
);
}
pub use hashmap;
}
pub mod hash_set {
#[cfg(feature = "fuzzing")]
pub type DefaultHashBuilder = crate::rust::collections::stub_hasher::StubHasher;
#[cfg(all(not(feature = "fuzzing"), feature = "alloc"))]
pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder;
#[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))]
pub type DefaultHashBuilder = std::collections::hash_map::RandomState;
#[cfg(feature = "alloc")]
pub use hashbrown::hash_set::*;
#[cfg(not(feature = "alloc"))]
pub use std::collections::hash_set::*;
#[cfg(feature = "alloc")]
pub use hashbrown::HashSet as ext_HashSet;
#[cfg(not(feature = "alloc"))]
pub use std::collections::HashSet as ext_HashSet;
pub type HashSet<K> = ext_HashSet<K, DefaultHashBuilder>;
pub fn new<K>() -> HashSet<K> {
HashSet::with_capacity_and_hasher(0, DefaultHashBuilder::default())
}
pub fn with_capacity<K>(n: usize) -> HashSet<K> {
HashSet::with_capacity_and_hasher(n, DefaultHashBuilder::default())
}
#[macro_export]
macro_rules! hashset {
( ) => ({
$crate::rust::collections::hash_set::HashSet::new()
});
( $($key:expr),* ) => ({
const CAP: usize = <[()]>::len(&[$({ stringify!($key); }),*]);
let mut temp = $crate::rust::collections::hash_set::HashSet::with_capacity(CAP);
$(
temp.insert($key);
)*
temp
});
( $($key:expr,)* ) => (
$crate::rust::collections::hash_set::hashset!{$($key),*}
);
}
pub use hashset;
}
pub mod index_map {
#[cfg(feature = "fuzzing")]
pub type DefaultHashBuilder = crate::rust::collections::stub_hasher::StubHasher;
#[cfg(all(not(feature = "fuzzing"), feature = "alloc"))]
pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder;
#[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))]
pub type DefaultHashBuilder = std::collections::hash_map::RandomState;
pub type IndexMap<K, V, S = DefaultHashBuilder> = indexmap::IndexMap<K, V, S>;
pub fn new<K, V>() -> IndexMap<K, V> {
IndexMap::with_capacity_and_hasher(0, DefaultHashBuilder::default())
}
pub fn with_capacity<K, V>(n: usize) -> IndexMap<K, V> {
IndexMap::with_capacity_and_hasher(n, DefaultHashBuilder::default())
}
#[macro_export]
macro_rules! indexmap {
( ) => ({
$crate::rust::collections::index_map_new()
});
($($key:expr => $value:expr,)+) => ( $crate::rust::collections::index_map::indexmap!{$($key => $value),*} );
($($key:expr => $value:expr),*) => ({
const CAP: usize = <[()]>::len(&[$({ stringify!($key); }),*]);
let mut temp = $crate::rust::collections::index_map::with_capacity(CAP);
$(
temp.insert($key, $value);
)*
temp
});
}
pub use indexmap;
}
pub mod index_set {
#[cfg(feature = "fuzzing")]
pub type DefaultHashBuilder = crate::rust::collections::stub_hasher::StubHasher;
#[cfg(all(not(feature = "fuzzing"), feature = "alloc"))]
pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder;
#[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))]
pub type DefaultHashBuilder = std::collections::hash_map::RandomState;
pub type IndexSet<K, S = DefaultHashBuilder> = indexmap::IndexSet<K, S>;
pub fn new<K>() -> IndexSet<K, DefaultHashBuilder> {
IndexSet::with_capacity_and_hasher(0, DefaultHashBuilder::default())
}
pub fn with_capacity<K>(n: usize) -> IndexSet<K, DefaultHashBuilder> {
IndexSet::with_capacity_and_hasher(n, DefaultHashBuilder::default())
}
#[macro_export]
macro_rules! indexset {
() => ({
$crate::rust::collections::index_set_new()
});
($($key:expr),+$(,)?) => ({
const CAP: usize = <[()]>::len(&[$({ stringify!($key); }),*]);
let mut temp = $crate::rust::collections::index_set::with_capacity(CAP);
$(
temp.insert($key);
)*
temp
});
}
pub use indexset;
}
pub mod non_iter_map {
#[cfg(feature = "alloc")]
use hashbrown::HashMap;
#[cfg(not(feature = "alloc"))]
use std::collections::HashMap;
#[cfg(feature = "alloc")]
use core::hash::Hash;
#[cfg(not(feature = "alloc"))]
use core::hash::Hash;
#[cfg(feature = "alloc")]
use core::borrow::Borrow;
#[cfg(not(feature = "alloc"))]
use std::borrow::Borrow;
#[cfg(feature = "fuzzing")]
pub type DefaultHashBuilder = crate::rust::collections::stub_hasher::StubHasher;
#[cfg(all(not(feature = "fuzzing"), feature = "alloc"))]
pub type DefaultHashBuilder = hashbrown::hash_map::DefaultHashBuilder;
#[cfg(all(not(feature = "fuzzing"), not(feature = "alloc")))]
pub type DefaultHashBuilder = std::collections::hash_map::RandomState;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NonIterMap<K: Eq + Hash, V, S: core::hash::BuildHasher = DefaultHashBuilder>(
HashMap<K, V, S>,
);
#[cfg(feature = "alloc")]
pub type Entry<'a, K, V> = hashbrown::hash_map::Entry<'a, K, V, DefaultHashBuilder>;
#[cfg(not(feature = "alloc"))]
pub type Entry<'a, K, V> = std::collections::hash_map::Entry<'a, K, V>;
impl<K: Hash + Eq, V> NonIterMap<K, V> {
pub fn new() -> Self {
Self(HashMap::with_capacity_and_hasher(
0,
DefaultHashBuilder::default(),
))
}
pub fn entry(&mut self, key: K) -> Entry<K, V> {
self.0.entry(key)
}
pub fn insert(&mut self, key: K, value: V) -> Option<V> {
self.0.insert(key, value)
}
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
where
Q: Hash + Eq,
K: Borrow<Q>,
{
self.0.get(key)
}
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V>
where
Q: Hash + Eq,
K: Borrow<Q>,
{
self.0.get_mut(key)
}
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
where
Q: Hash + Eq,
K: Borrow<Q>,
{
self.0.contains_key(key)
}
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
where
Q: Hash + Eq,
K: Borrow<Q>,
{
self.0.remove(key)
}
pub fn clear(&mut self) {
self.0.clear();
}
pub fn len(&self) -> usize {
self.0.len()
}
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}
impl<K: Hash + Eq, V> Default for NonIterMap<K, V> {
fn default() -> Self {
Self::new()
}
}
impl<K: Hash + Eq, V> FromIterator<(K, V)> for NonIterMap<K, V> {
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
Self(HashMap::from_iter(iter))
}
}
}
pub use btree_map::btreemap;
pub use btree_map::BTreeMap;
pub use btree_set::btreeset;
pub use btree_set::BTreeSet;
pub use hash_map::hashmap;
pub use hash_map::HashMap;
pub use hash_map::{new as hash_map_new, with_capacity as hash_map_with_capacity};
pub use hash_set::hashset;
pub use hash_set::HashSet;
pub use hash_set::{new as hash_set_new, with_capacity as hash_set_with_capacity};
pub use index_map::indexmap;
pub use index_map::IndexMap;
pub use index_map::{new as index_map_new, with_capacity as index_map_with_capacity};
pub use index_set::indexset;
pub use index_set::IndexSet;
pub use index_set::{new as index_set_new, with_capacity as index_set_with_capacity};
pub use non_iter_map::NonIterMap;
}