11use crate :: simd:: intrinsics;
2- use crate :: { LaneCount , Simd , SimdElement , SupportedLaneCount } ;
2+ use crate :: simd :: { LaneCount , Simd , SimdElement , SupportedLaneCount } ;
33
44/// Constructs a new vector by selecting values from the lanes of the source vector or vectors to use.
55///
@@ -12,7 +12,8 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
1212/// ## One source vector
1313/// ```
1414/// # #![feature(portable_simd)]
15- /// # use core_simd::{Simd, simd_swizzle};
15+ /// # #[cfg(feature = "std")] use core_simd::{Simd, simd_swizzle};
16+ /// # #[cfg(not(feature = "std"))] use core::simd::{Simd, simd_swizzle};
1617/// let v = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
1718///
1819/// // Keeping the same size
@@ -27,7 +28,8 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
2728/// ## Two source vectors
2829/// ```
2930/// # #![feature(portable_simd)]
30- /// # use core_simd::{Simd, simd_swizzle, Which};
31+ /// # #[cfg(feature = "std")] use core_simd::{Simd, simd_swizzle, Which};
32+ /// # #[cfg(not(feature = "std"))] use core::simd::{Simd, simd_swizzle, Which};
3133/// use Which::*;
3234/// let a = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
3335/// let b = Simd::<f32, 4>::from_array([4., 5., 6., 7.]);
@@ -40,11 +42,11 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
4042/// let r = simd_swizzle!(a, b, [First(0), Second(0)]);
4143/// assert_eq!(r.to_array(), [0., 4.]);
4244/// ```
43- #[ macro_export ]
44- macro_rules! simd_swizzle {
45- {
45+ #[ allow ( unused_macros ) ]
46+ pub macro simd_swizzle {
47+ (
4648 $vector: expr, $index: expr $( , ) ?
47- } => {
49+ ) => {
4850 {
4951 use $crate:: simd:: Swizzle ;
5052 struct Impl ;
@@ -53,10 +55,10 @@ macro_rules! simd_swizzle {
5355 }
5456 Impl :: swizzle ( $vector)
5557 }
56- } ;
57- {
58+ } ,
59+ (
5860 $first: expr, $second: expr, $index: expr $( , ) ?
59- } => {
61+ ) => {
6062 {
6163 use $crate:: simd:: { Which , Swizzle2 } ;
6264 struct Impl ;
@@ -262,7 +264,8 @@ where
262264 ///
263265 /// ```
264266 /// #![feature(portable_simd)]
265- /// # use core_simd::Simd;
267+ /// # #[cfg(feature = "std")] use core_simd::Simd;
268+ /// # #[cfg(not(feature = "std"))] use core::simd::Simd;
266269 /// let a = Simd::from_array([0, 1, 2, 3]);
267270 /// let b = Simd::from_array([4, 5, 6, 7]);
268271 /// let (x, y) = a.interleave(b);
@@ -324,7 +327,8 @@ where
324327 ///
325328 /// ```
326329 /// #![feature(portable_simd)]
327- /// # use core_simd::Simd;
330+ /// # #[cfg(feature = "std")] use core_simd::Simd;
331+ /// # #[cfg(not(feature = "std"))] use core::simd::Simd;
328332 /// let a = Simd::from_array([0, 4, 1, 5]);
329333 /// let b = Simd::from_array([2, 6, 3, 7]);
330334 /// let (x, y) = a.deinterleave(b);
0 commit comments