Make macros work without any other imports

This commit is contained in:
Wim Looman
2020-01-28 12:46:39 +01:00
parent 5e46d949af
commit 45275fbbc2
3 changed files with 9 additions and 8 deletions
+3 -3
View File
@@ -19,13 +19,13 @@ use super::*;
macro_rules! array_vec {
($array_type:ty) => {
{
let av: ArrayVec<$array_type> = Default::default();
let av: $crate::ArrayVec<$array_type> = Default::default();
av
}
};
($array_type:ty, $($elem:expr),*) => {
{
let mut av: ArrayVec<$array_type> = Default::default();
let mut av: $crate::ArrayVec<$array_type> = Default::default();
$( av.push($elem); )*
av
}
@@ -251,7 +251,7 @@ impl<A: Array> ArrayVec<A> {
}
/// Clone each element of the slice into this `ArrayVec`.
///
///
/// ## Panics
/// * If the `ArrayVec` would overflow, this will panic.
#[inline]
+2 -1
View File
@@ -75,7 +75,8 @@ use core::{
};
#[cfg(feature = "alloc")]
extern crate alloc;
#[doc(hidden)] // re-export for macros
pub extern crate alloc;
mod array;
pub use array::*;
+4 -4
View File
@@ -25,7 +25,7 @@ use alloc::vec::Vec;
macro_rules! tiny_vec {
($array_type:ty) => {
{
let mut tv: TinyVec<$array_type> = Default::default();
let mut tv: $crate::TinyVec<$array_type> = Default::default();
tv
}
};
@@ -42,10 +42,10 @@ macro_rules! tiny_vec {
const INVOKED_ELEM_COUNT: usize = 0 $( + { let _ = stringify!($elem); 1 })*;
// If we have more `$elem` than the `CAPACITY` we will simply go directly
// to constructing on the heap.
let av: TinyVec<$array_type> = if INVOKED_ELEM_COUNT <= <$array_type as Array>::CAPACITY {
TinyVec::<$array_type>::Inline(array_vec!($array_type, $($elem),*))
let av: $crate::TinyVec<$array_type> = if INVOKED_ELEM_COUNT <= <$array_type as $crate::Array>::CAPACITY {
$crate::TinyVec::<$array_type>::Inline($crate::array_vec!($array_type, $($elem),*))
} else {
TinyVec::<$array_type>::Heap(vec!($($elem),*))
$crate::TinyVec::<$array_type>::Heap($crate::alloc::vec!($($elem),*))
};
av
}