@@ -129,6 +129,7 @@ where
129129 /// # Safety
130130 /// All lanes must be either 0 or -1.
131131 #[ inline]
132+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
132133 pub unsafe fn from_int_unchecked ( value : Simd < T , LANES > ) -> Self {
133134 unsafe { Self ( mask_impl:: Mask :: from_int_unchecked ( value) ) }
134135 }
@@ -139,6 +140,7 @@ where
139140 /// # Panics
140141 /// Panics if any lane is not 0 or -1.
141142 #[ inline]
143+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
142144 pub fn from_int ( value : Simd < T , LANES > ) -> Self {
143145 assert ! ( T :: valid( value) , "all values must be either 0 or -1" , ) ;
144146 unsafe { Self :: from_int_unchecked ( value) }
@@ -147,6 +149,7 @@ where
147149 /// Converts the mask to a vector of integers, where 0 represents `false` and -1
148150 /// represents `true`.
149151 #[ inline]
152+ #[ must_use = "method returns a new vector and does not mutate the original value" ]
150153 pub fn to_int ( self ) -> Simd < T , LANES > {
151154 self . 0 . to_int ( )
152155 }
@@ -156,6 +159,7 @@ where
156159 /// # Safety
157160 /// `lane` must be less than `LANES`.
158161 #[ inline]
162+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
159163 pub unsafe fn test_unchecked ( & self , lane : usize ) -> bool {
160164 unsafe { self . 0 . test_unchecked ( lane) }
161165 }
@@ -165,6 +169,7 @@ where
165169 /// # Panics
166170 /// Panics if `lane` is greater than or equal to the number of lanes in the vector.
167171 #[ inline]
172+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
168173 pub fn test ( & self , lane : usize ) -> bool {
169174 assert ! ( lane < LANES , "lane index out of range" ) ;
170175 unsafe { self . test_unchecked ( lane) }
@@ -195,24 +200,30 @@ where
195200
196201 /// Convert this mask to a bitmask, with one bit set per lane.
197202 #[ cfg( feature = "generic_const_exprs" ) ]
203+ #[ inline]
204+ #[ must_use = "method returns a new array and does not mutate the original value" ]
198205 pub fn to_bitmask ( self ) -> [ u8 ; LaneCount :: < LANES > :: BITMASK_LEN ] {
199206 self . 0 . to_bitmask ( )
200207 }
201208
202209 /// Convert a bitmask to a mask.
203210 #[ cfg( feature = "generic_const_exprs" ) ]
211+ #[ inline]
212+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
204213 pub fn from_bitmask ( bitmask : [ u8 ; LaneCount :: < LANES > :: BITMASK_LEN ] ) -> Self {
205214 Self ( mask_impl:: Mask :: from_bitmask ( bitmask) )
206215 }
207216
208217 /// Returns true if any lane is set, or false otherwise.
209218 #[ inline]
219+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
210220 pub fn any ( self ) -> bool {
211221 self . 0 . any ( )
212222 }
213223
214224 /// Returns true if all lanes are set, or false otherwise.
215225 #[ inline]
226+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
216227 pub fn all ( self ) -> bool {
217228 self . 0 . all ( )
218229 }
@@ -245,6 +256,7 @@ where
245256 LaneCount < LANES > : SupportedLaneCount ,
246257{
247258 #[ inline]
259+ #[ must_use = "method returns a defaulted mask with all lanes set to false (0)" ]
248260 fn default ( ) -> Self {
249261 Self :: splat ( false )
250262 }
@@ -256,6 +268,7 @@ where
256268 LaneCount < LANES > : SupportedLaneCount ,
257269{
258270 #[ inline]
271+ #[ must_use = "method returns a new bool and does not mutate the original value" ]
259272 fn eq ( & self , other : & Self ) -> bool {
260273 self . 0 == other. 0
261274 }
@@ -267,6 +280,7 @@ where
267280 LaneCount < LANES > : SupportedLaneCount ,
268281{
269282 #[ inline]
283+ #[ must_use = "method returns a new Ordering and does not mutate the original value" ]
270284 fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
271285 self . 0 . partial_cmp ( & other. 0 )
272286 }
@@ -291,6 +305,7 @@ where
291305{
292306 type Output = Self ;
293307 #[ inline]
308+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
294309 fn bitand ( self , rhs : Self ) -> Self {
295310 Self ( self . 0 & rhs. 0 )
296311 }
@@ -303,6 +318,7 @@ where
303318{
304319 type Output = Self ;
305320 #[ inline]
321+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
306322 fn bitand ( self , rhs : bool ) -> Self {
307323 self & Self :: splat ( rhs)
308324 }
@@ -315,6 +331,7 @@ where
315331{
316332 type Output = Mask < T , LANES > ;
317333 #[ inline]
334+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
318335 fn bitand ( self , rhs : Mask < T , LANES > ) -> Mask < T , LANES > {
319336 Mask :: splat ( self ) & rhs
320337 }
@@ -327,6 +344,7 @@ where
327344{
328345 type Output = Self ;
329346 #[ inline]
347+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
330348 fn bitor ( self , rhs : Self ) -> Self {
331349 Self ( self . 0 | rhs. 0 )
332350 }
@@ -339,6 +357,7 @@ where
339357{
340358 type Output = Self ;
341359 #[ inline]
360+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
342361 fn bitor ( self , rhs : bool ) -> Self {
343362 self | Self :: splat ( rhs)
344363 }
@@ -351,6 +370,7 @@ where
351370{
352371 type Output = Mask < T , LANES > ;
353372 #[ inline]
373+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
354374 fn bitor ( self , rhs : Mask < T , LANES > ) -> Mask < T , LANES > {
355375 Mask :: splat ( self ) | rhs
356376 }
@@ -363,6 +383,7 @@ where
363383{
364384 type Output = Self ;
365385 #[ inline]
386+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
366387 fn bitxor ( self , rhs : Self ) -> Self :: Output {
367388 Self ( self . 0 ^ rhs. 0 )
368389 }
@@ -375,6 +396,7 @@ where
375396{
376397 type Output = Self ;
377398 #[ inline]
399+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
378400 fn bitxor ( self , rhs : bool ) -> Self :: Output {
379401 self ^ Self :: splat ( rhs)
380402 }
@@ -387,6 +409,7 @@ where
387409{
388410 type Output = Mask < T , LANES > ;
389411 #[ inline]
412+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
390413 fn bitxor ( self , rhs : Mask < T , LANES > ) -> Self :: Output {
391414 Mask :: splat ( self ) ^ rhs
392415 }
@@ -399,6 +422,7 @@ where
399422{
400423 type Output = Mask < T , LANES > ;
401424 #[ inline]
425+ #[ must_use = "method returns a new mask and does not mutate the original value" ]
402426 fn not ( self ) -> Self :: Output {
403427 Self ( !self . 0 )
404428 }
0 commit comments