1
1
use crate :: simd:: intrinsics;
2
- use crate :: { LaneCount , Simd , SimdElement , SupportedLaneCount } ;
2
+ use crate :: simd :: { LaneCount , Simd , SimdElement , SupportedLaneCount } ;
3
3
4
4
/// Constructs a new vector by selecting values from the lanes of the source vector or vectors to use.
5
5
///
@@ -12,7 +12,8 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
12
12
/// ## One source vector
13
13
/// ```
14
14
/// # #![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};
16
17
/// let v = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
17
18
///
18
19
/// // Keeping the same size
@@ -27,7 +28,8 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
27
28
/// ## Two source vectors
28
29
/// ```
29
30
/// # #![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};
31
33
/// use Which::*;
32
34
/// let a = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
33
35
/// let b = Simd::<f32, 4>::from_array([4., 5., 6., 7.]);
@@ -40,11 +42,11 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
40
42
/// let r = simd_swizzle!(a, b, [First(0), Second(0)]);
41
43
/// assert_eq!(r.to_array(), [0., 4.]);
42
44
/// ```
43
- #[ macro_export ]
44
- macro_rules! simd_swizzle {
45
- {
45
+ #[ allow ( unused_macros ) ]
46
+ pub macro simd_swizzle {
47
+ (
46
48
$vector: expr, $index: expr $( , ) ?
47
- } => {
49
+ ) => {
48
50
{
49
51
use $crate:: simd:: Swizzle ;
50
52
struct Impl ;
@@ -53,10 +55,10 @@ macro_rules! simd_swizzle {
53
55
}
54
56
Impl :: swizzle ( $vector)
55
57
}
56
- } ;
57
- {
58
+ } ,
59
+ (
58
60
$first: expr, $second: expr, $index: expr $( , ) ?
59
- } => {
61
+ ) => {
60
62
{
61
63
use $crate:: simd:: { Which , Swizzle2 } ;
62
64
struct Impl ;
@@ -262,7 +264,8 @@ where
262
264
///
263
265
/// ```
264
266
/// #![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;
266
269
/// let a = Simd::from_array([0, 1, 2, 3]);
267
270
/// let b = Simd::from_array([4, 5, 6, 7]);
268
271
/// let (x, y) = a.interleave(b);
@@ -324,7 +327,8 @@ where
324
327
///
325
328
/// ```
326
329
/// #![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;
328
332
/// let a = Simd::from_array([0, 4, 1, 5]);
329
333
/// let b = Simd::from_array([2, 6, 3, 7]);
330
334
/// let (x, y) = a.deinterleave(b);
0 commit comments