@@ -129,6 +129,7 @@ where
129
129
/// # Safety
130
130
/// All lanes must be either 0 or -1.
131
131
#[ inline]
132
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
132
133
pub unsafe fn from_int_unchecked ( value : Simd < T , LANES > ) -> Self {
133
134
unsafe { Self ( mask_impl:: Mask :: from_int_unchecked ( value) ) }
134
135
}
@@ -139,6 +140,7 @@ where
139
140
/// # Panics
140
141
/// Panics if any lane is not 0 or -1.
141
142
#[ inline]
143
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
142
144
pub fn from_int ( value : Simd < T , LANES > ) -> Self {
143
145
assert ! ( T :: valid( value) , "all values must be either 0 or -1" , ) ;
144
146
unsafe { Self :: from_int_unchecked ( value) }
@@ -147,6 +149,7 @@ where
147
149
/// Converts the mask to a vector of integers, where 0 represents `false` and -1
148
150
/// represents `true`.
149
151
#[ inline]
152
+ #[ must_use = "method returns a new vector and does not mutate the original value" ]
150
153
pub fn to_int ( self ) -> Simd < T , LANES > {
151
154
self . 0 . to_int ( )
152
155
}
@@ -156,6 +159,7 @@ where
156
159
/// # Safety
157
160
/// `lane` must be less than `LANES`.
158
161
#[ inline]
162
+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
159
163
pub unsafe fn test_unchecked ( & self , lane : usize ) -> bool {
160
164
unsafe { self . 0 . test_unchecked ( lane) }
161
165
}
@@ -165,6 +169,7 @@ where
165
169
/// # Panics
166
170
/// Panics if `lane` is greater than or equal to the number of lanes in the vector.
167
171
#[ inline]
172
+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
168
173
pub fn test ( & self , lane : usize ) -> bool {
169
174
assert ! ( lane < LANES , "lane index out of range" ) ;
170
175
unsafe { self . test_unchecked ( lane) }
@@ -195,24 +200,30 @@ where
195
200
196
201
/// Convert this mask to a bitmask, with one bit set per lane.
197
202
#[ cfg( feature = "generic_const_exprs" ) ]
203
+ #[ inline]
204
+ #[ must_use = "method returns a new array and does not mutate the original value" ]
198
205
pub fn to_bitmask ( self ) -> [ u8 ; LaneCount :: < LANES > :: BITMASK_LEN ] {
199
206
self . 0 . to_bitmask ( )
200
207
}
201
208
202
209
/// Convert a bitmask to a mask.
203
210
#[ cfg( feature = "generic_const_exprs" ) ]
211
+ #[ inline]
212
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
204
213
pub fn from_bitmask ( bitmask : [ u8 ; LaneCount :: < LANES > :: BITMASK_LEN ] ) -> Self {
205
214
Self ( mask_impl:: Mask :: from_bitmask ( bitmask) )
206
215
}
207
216
208
217
/// Returns true if any lane is set, or false otherwise.
209
218
#[ inline]
219
+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
210
220
pub fn any ( self ) -> bool {
211
221
self . 0 . any ( )
212
222
}
213
223
214
224
/// Returns true if all lanes are set, or false otherwise.
215
225
#[ inline]
226
+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
216
227
pub fn all ( self ) -> bool {
217
228
self . 0 . all ( )
218
229
}
@@ -245,6 +256,7 @@ where
245
256
LaneCount < LANES > : SupportedLaneCount ,
246
257
{
247
258
#[ inline]
259
+ #[ must_use = "method returns a defaulted mask with all lanes set to false (0)" ]
248
260
fn default ( ) -> Self {
249
261
Self :: splat ( false )
250
262
}
@@ -256,6 +268,7 @@ where
256
268
LaneCount < LANES > : SupportedLaneCount ,
257
269
{
258
270
#[ inline]
271
+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
259
272
fn eq ( & self , other : & Self ) -> bool {
260
273
self . 0 == other. 0
261
274
}
@@ -267,6 +280,7 @@ where
267
280
LaneCount < LANES > : SupportedLaneCount ,
268
281
{
269
282
#[ inline]
283
+ #[ must_use = "method returns a new Ordering and does not mutate the original value" ]
270
284
fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
271
285
self . 0 . partial_cmp ( & other. 0 )
272
286
}
@@ -291,6 +305,7 @@ where
291
305
{
292
306
type Output = Self ;
293
307
#[ inline]
308
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
294
309
fn bitand ( self , rhs : Self ) -> Self {
295
310
Self ( self . 0 & rhs. 0 )
296
311
}
@@ -303,6 +318,7 @@ where
303
318
{
304
319
type Output = Self ;
305
320
#[ inline]
321
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
306
322
fn bitand ( self , rhs : bool ) -> Self {
307
323
self & Self :: splat ( rhs)
308
324
}
@@ -315,6 +331,7 @@ where
315
331
{
316
332
type Output = Mask < T , LANES > ;
317
333
#[ inline]
334
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
318
335
fn bitand ( self , rhs : Mask < T , LANES > ) -> Mask < T , LANES > {
319
336
Mask :: splat ( self ) & rhs
320
337
}
@@ -327,6 +344,7 @@ where
327
344
{
328
345
type Output = Self ;
329
346
#[ inline]
347
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
330
348
fn bitor ( self , rhs : Self ) -> Self {
331
349
Self ( self . 0 | rhs. 0 )
332
350
}
@@ -339,6 +357,7 @@ where
339
357
{
340
358
type Output = Self ;
341
359
#[ inline]
360
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
342
361
fn bitor ( self , rhs : bool ) -> Self {
343
362
self | Self :: splat ( rhs)
344
363
}
@@ -351,6 +370,7 @@ where
351
370
{
352
371
type Output = Mask < T , LANES > ;
353
372
#[ inline]
373
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
354
374
fn bitor ( self , rhs : Mask < T , LANES > ) -> Mask < T , LANES > {
355
375
Mask :: splat ( self ) | rhs
356
376
}
@@ -363,6 +383,7 @@ where
363
383
{
364
384
type Output = Self ;
365
385
#[ inline]
386
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
366
387
fn bitxor ( self , rhs : Self ) -> Self :: Output {
367
388
Self ( self . 0 ^ rhs. 0 )
368
389
}
@@ -375,6 +396,7 @@ where
375
396
{
376
397
type Output = Self ;
377
398
#[ inline]
399
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
378
400
fn bitxor ( self , rhs : bool ) -> Self :: Output {
379
401
self ^ Self :: splat ( rhs)
380
402
}
@@ -387,6 +409,7 @@ where
387
409
{
388
410
type Output = Mask < T , LANES > ;
389
411
#[ inline]
412
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
390
413
fn bitxor ( self , rhs : Mask < T , LANES > ) -> Self :: Output {
391
414
Mask :: splat ( self ) ^ rhs
392
415
}
@@ -399,6 +422,7 @@ where
399
422
{
400
423
type Output = Mask < T , LANES > ;
401
424
#[ inline]
425
+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
402
426
fn not ( self ) -> Self :: Output {
403
427
Self ( !self . 0 )
404
428
}
0 commit comments