File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -103,16 +103,28 @@ macro_rules! types {
103
103
unsafe { simd_shuffle!( one, one, [ 0 ; $len] ) }
104
104
}
105
105
106
+ /// Constructs a vector from an array of the same elements and length
107
+ ///
108
+ /// For now you don't *have* to use this to construct one of these
109
+ /// (depending on the visibility you put on the field) but it's encouraged
110
+ /// in case direct construction also gets banned.
111
+ #[ inline]
112
+ $v const fn from_array( array: [ $elem_type; $len] ) -> Self {
113
+ // Projecting into SIMD is banned, but this is technically an
114
+ // `Rvalue::Aggregate`, which is not a projection.
115
+ $name { do_not_field_project: array }
116
+ }
117
+
106
118
/// Returns an array reference containing the entire SIMD vector.
119
+ #[ inline]
107
120
$v const fn as_array( & self ) -> & [ $elem_type; $len] {
108
121
// SAFETY: this type is just an overaligned `[T; N]` with
109
122
// potential padding at the end, so pointer casting to a
110
123
// `&[T; N]` is safe.
111
124
//
112
- // NOTE: This deliberately doesn't just use `&self.0` because it may soon be banned
125
+ // NOTE: This deliberately doesn't just use `&self.0` it's banned
113
126
// see https://github.com/rust-lang/compiler-team/issues/838
114
127
unsafe { & * ( self as * const Self as * const [ $elem_type; $len] ) }
115
-
116
128
}
117
129
118
130
/// Returns a mutable array reference containing the entire SIMD vector.
You can’t perform that action at this time.
0 commit comments